Helpful Information
 
 
Category: Apache Development
Redirect to ip with appropriate URL?

Hello,

I need to redirect using apache on a linux box to a development server IP address using a domain name that isn't registered to the IP. In other words when the redirect happens I need the development server to think that the domain name is http://www.xyz.com, because I capture the domain name through an environmental variable. I can handle the redirect with no problem through apache but the domain name is not correct.

On my NT box I just change the host file and when I type http://www.xyz.com in the browser everything works fine. I changed the hosts and lmhosts files on the linux box and they come up with the correct IP when I ping the fake domain name but the redirect still doesn't work.

Any ideas, did I totally explain that poorly?

>>using a domain name that isn't registered to the IP

Are you talking about internal web server with only internal request?

>>Any ideas, did I totally explain that poorly?

Yes, a bit.

Both web servers are on the net in two completely different locations.

I want the linux box to redirect to the ip of my development servers but with the domain name of my specification. So I could have two different domain names going to the same IP: http://www.xyz.com, http://www.123.com from my Linux box. The catch is neither of these domain names is registered to that ip.

As I said in my previous post I can accomplish this with my NT workstation by changing the host file so when I type http://www.xyz.com or http://www.123.com in my browser it will go to the IP of my designation and the site will recognize the domain name that was typed in(I assume it was in the http header). I was hoping I could do something similar with the Linux box but I can't seem to.

Don't know if this clears anything up.
Thanks for the help.

>> I changed the hosts and lmhosts files on the linux box

Keep in mind, /etc/hosts is just your local resolver, it just work locally.

>> Both web servers are on the net in two completely different locations

Then you should check out mod_proxy and mod_rewrite.

Anyway, still not enough info.
1) What are the IPs (make them up) for your NT box and Linux box?
2) What is the forward nslookup for http://www.xyz.com and http://www.123.com?

>> I changed the hosts and lmhosts files on the linux box and they come up with the correct IP

Again, which correct IP?

>> when I ping the fake domain name

Which fake domain? BTW, how do you define fake domain in your case?

The short version:

I have an apache server on http://www.linuxbox.com (123.45.67.890).
I have a development server on 001.02.03.004.

I set up in the http://www.linuxbox.com hostfile a domain name http://www.xyz.com(a fake domain name) and pointed it at the ip 001.02.03.004, I can ping http://www.xyz.com and it shows a ping of 001.02.03.004. So I set up a redirect to http://www.xyz.com, on the apache server at http://www.linuxbox.com, using mod_alias hoping it would redirect a browser to the IP 001.02.03.004 with the URL http://www.xyz.com in the browser's address box, it didn't.

How do I get apache to redirect a browser to the IP 001.02.03.04 with the domain name http://www.xyz.com showing in the browser's address box? I see how to redirect in mod_rewrite but not how to accomplish what I need with the domain name showing in the browser's address box.

As I said, /etc/hosts file is for local use, so it might work for you locally but not for others who try to reach your site. You need to run nameserver and you can't put whatever fake domain you like to /etc/hosts and expect it to work, yes locally, but not on the net.

Say you put 123.45.67.89 www.yahoo.com in /etc/hosts, that doesn't work because forward dns lookup of http://www.yahoo.com doesn't point to 123.45.67.89.










privacy (GDPR)