homepage Welcome to WebmasterWorld Guest from 54.145.172.149
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess redirect for multiple domains
Gremlin098

5+ Year Member



 
Msg#: 3647574 posted 12:57 am on May 12, 2008 (gmt 0)

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?

 

jdMorgan

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



 
Msg#: 3647574 posted 2:47 am on May 12, 2008 (gmt 0)

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

Gremlin098

5+ Year Member



 
Msg#: 3647574 posted 3:39 pm on May 12, 2008 (gmt 0)

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]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3647574 posted 8:39 pm on May 12, 2008 (gmt 0)

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.

Gremlin098

5+ Year Member



 
Msg#: 3647574 posted 9:17 pm on May 12, 2008 (gmt 0)

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?

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3647574 posted 9:46 pm on May 12, 2008 (gmt 0)

It could do. It's Duplicate Content.

Re-examine your rules in detail.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved