views:

82

answers:

2

The setup is:

  • www.domainA.com
  • www.domainB.com

both actually hosted on one web server (Apache)

  • 123.123.123.123/domainA
  • 123.123.123.123/domainB

I have setup a hidden forward from the domains to the web server directories which works fine, however, produces duplicate content (since it is also available by addressing the web server directly). I tried setting up 301 redirects to the domains for every request that is targeting the IP address directly (using mod_rewrite),but found that this results in a forwarding loop. Obviously the server does not recognize whether the domain has been requested originally.

If anybody can give me a hint on how this is supposed to be done, I'd be glad to hear.

+2  A: 

You can set up virtual hosting on the web-server so that it does pay attention to the hostname that was requested. This is a fairly common practice and should solve your problem. You can do away with separate subdirectories since each virtual host has its own virtual root.

Mr. Shiny and New
+1 - didn't even think that he might not be using virtual hosts..
Eric Petroelje
Thanks a lot... "virtualhost" just seems to be the keyword that refused to come into my thougts :)
peter p
A: 

So are you saying that you have pages indexed in google that reference your IP address and a directory rather than the domain name?

Also, I'm not sure why doing a redirect from the IP to the domain name would cause a redirect loop. If the redirect is based on the host header, it should work fine.

Eric Petroelje