Welcome to WebmasterWorld Guest from 54.147.220.66

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess redirect for multiple domains

   
12:57 am on May 12, 2008 (gmt 0)

5+ Year Member



I have a few different domain names on my hosting and would like to use an htaccess redirect to send each one to a different subfolder. Does anyone know what the redirect would look like?
2:47 am on May 12, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi Gremlin, and welcome to WebmasterWorld!

We've covered many variations of this subject in previous threads [google.com]. Please take a look through those, review the documentation and tutorials cited in our Forum Charter, check the Apache Forum Library, and then post specific questions back here.

Thanks,
Jim

3:39 pm on May 12, 2008 (gmt 0)

5+ Year Member



When you say "we" I think you mean you. I searched your screen name and found just about every variation I could think of. The code below worked nicely. Thanks very much!

Options +FollowSymLinks
RewriteEngine on

# redirect to add "www" prefix for existing or new domain
RewriteCond %{HTTP_HOST} ^existing-domain\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^new-domain\.com [NC]
RewriteRule (.*) [%{HTTP_HOST}...] [R=301,L]

# Internally rewrite new domain home page requests to a specific page
RewriteCond %{HTTP_HOST} ^www\.newdomain\.com
RewriteRule ^$ /specific-page.html [L]

8:39 pm on May 12, 2008 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Make sure you test it for both non-www and www starting points.

Try it for the root domain, and for folders, and for files, and for files in folders to be sure.

9:17 pm on May 12, 2008 (gmt 0)

5+ Year Member



It seems to work fine. One minor issue, but I'm not sure its a problem. On redirects to the root, I'm getting two trailing slashes - almost like it assumes a path or file name will follow. It doesn't seem to affect functionality though. Do you think it will cause problems with search engines?
9:46 pm on May 12, 2008 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



It could do. It's Duplicate Content.

Re-examine your rules in detail.