mod_rewrite redirecting multiple domain names to the one name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a web server set up with 3 different domain names registered.  For simplicity, I'll call them...
http://site1.com
http://site2.com
http://site3.com

I want http://site1.com to be the name people remember, so no matter which URL they use to get to the site, they are redirected to http://site1.com.

Here's a quick excerpt of the httpd.conf file on attempt #1:
LoadModule rewrite_module modules/mod_rewrite.so
ServerName site1.com
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^site1\.com [NC]   #same result with or without this line
RewriteRule /test.html$ http://site1.com/test.html [R=301,L]

Intended result...
Enter: http://site2.com/test.html
Redirected to: http://site1.com/test.html

If I change the rewrite rule to redirect to http://www.google.com, it redirects there successfully.  So it seems that no matter what hostname is used in the request, Apache thinks the http_host is site1.com.  And yes, unfortunately I do need to redirect back to the same page (test.html) in this instance.


I figure this is a fairly common problem, but I haven't been able to find any examples of how this is usually done.  I'm not convinced that this is best done in the Apache config.  Is this done at the DNS instead?

If you need any more information, please let me know.  Any assistance will be greatly appreciated.
Thanks.

-Viv-

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux