0
votes

I have been using apache server. I want to redirect some URL to another, eg. www.abc.com to localhost:8080/Home

I uncommented rewrite module in httpd.conf in conf folder of apache installation. Then I wrote rewrite rule like show below in httpd.conf file.

RewriteEngine On # Turn on the rewriting engine RewriteRule http://www.abc.com http://localhost:8080/Home/

But nothing happened. It is simply opening abc.com as normal. There is no error message not even in log.

Can anyone suggest where the problem is?

2

2 Answers

0
votes

You can only rewrite URLs that have the server as a host. Since you do not host www.abc.com, you cannot rewrite any of its URLs.

0
votes

It's not the 'best' solution, but I use it at home.

Edit the 'hosts' file on your own PC to redirect. For example, mine redirects 'attic' to ip 10.0.0.5, my server in the attic. So when I type attic/myfolder, I get what I would normally get at 10.0.0.5/myfolder.

Your hosts default location can be found with a very quick google.

Not the best, as I say, but it works.

EDIT:

Okay, something.something, we'll call it xyz.com.

We need 2 things here;

a) your server must expect traffic from xyz.com 
(this is just a config on the server, easy to achieve).

b) your browser must be pointed to your server when you type xyz.com.

Normally, when you type xyz.com into any browser, your PC will connect to a DNS server to find out where in the world xyz.com actually is (the DNS server returns an IP address). To inform the DNS servers that xyz.com should point to YOUR server, you need to pay to register the domain name with a registrar (unassigned domains aren't expensive). This is the best way, as every computer will now know how to get to your server by typing xyz.com. When you move your website to a hosted server, you go to your registrar's website and change the settings, saying "stop pointing to the IP of my home server and start poionting to the IP of my hosted server".

Or, if you don't want to do that, you need to tell YOUR PC to skip the DNS check, and you do that by modifying your hosts file as above. This will only work for you, but is enough for home testing purposes.

The third option is running your own DNS server, and manually telling it to override the world-wide settings for xyz.com. That way your browser would get your custom result when it checks the DNS server, and forward straight to your server. However, running your own DNS server is a complex undertaking, and is overkill for your current task.

In summary, from best option to worst: 1) Register your domain and point it home 2) Modify your hosts file to bypass DNS checking 3) Run your own DNS server, and override the settings for xyz.com

Hope I've been more clear this time :O)