Hi, I have a linux server and have run into a issue. I host 2 websites off of 1 server. I did a 301 redirect in the .httacess file on each domain to have it redirct to the www. domain. For example when a user goes to: site1.com it would redirect them to www.site1.com However my second domain it does not work this way, when I go to site2.com it redirects me to www.site1.com How can I get my second domain to redirect me to www.site 2.com? Here is part of my httacess file that deals with redirect for 1 domain, both are same , except where the domain name goes is changed to reflect the domain RewriteCond %{HTTP_HOST} !^www\.site1\.com RewriteRule (.*) http://www.site1.com/$1 [L,R=301] Code (markup): Thanks in advance
You'll have to figure out what you're actually trying to achieve. At the moment your rule says: 1) If the domain someone used is NOT www.site1.com 2) Then send them to www.site1.com www.site2.com is not www.site1.com, so it is dutifully sending them to www.site1.com. Perhaps you'd like to instead say: 1) If the domain someone used IS site1.com 2) Then send them to www.site1.com 3) If the domain someone used IS site2.com 4) Then send them to www.site2.com Of course, if someone gets there with www.site3.com or something, then they are left alone. To do this you just need: RewriteCond %{HTTP_HOST} ^site1\.com RewriteRule (.*) http://www.site1.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^site2\.com RewriteRule (.*) http://www.site2.com/$1 [L,R=301] Code (markup):
Thanks, to clearify I have 2 httacces files in each directory, one for site 1 and another for site 2. Does this mean to do what you said above to both httacces's
They are in diffrent dircetories. Site 1 is in /root/home/site1/public_html/ site 2 is in /root/home/site2/public_html/ each site has its own access, so which one do I edit?