Forum Moderators: phranque

Message Too Old, No Replies

.htaccess mod rewrite help

Multiple domains point to same directory

         

tankgirlpdx

2:53 pm on Mar 11, 2008 (gmt 0)

10+ Year Member



I'm a complete novice to .htaccess editing. I have a scenario that I'd like some help on (I did do a search of the site and didn't find anything specific to my question).

Scenario:

www.domain1.com (primary acct.)
www.domain2.com (add-on domain)
www.domain3.com (add-on domain)

I'd like to be able to point all 3 to the primary account public_html folder. However, when the user comes in as www.domain2.com or www.domain3.com, I'd like for the user to continue seeing that domain in the addressbar.

None of these are high-traffic sites.

I did find a bit of info, but it's doesn't seem to work...puts my add-on domain into what appears to be an infinite loop.

Could someone please let me know where the code is incorrect...corrections are completely welcome? Also, I have no idea how to add the third domain.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain1.com$ [NC]
RewriteRule ^(.*)$ [domain2.com...] [R,L]

Much appreciation in advance for any help given.

jdMorgan

3:09 pm on Mar 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need *any* code to point all domains to the main directory.

What you do need is correctly-configured DNS, and the server must be configured to recognize all the domains that are pointed to it.

You code says, "if the requested domain is not domain1, redirect the request to domain2." So, of course, after the first redirect, the requested domain is now doamin2, which is not domain1, so you get another redirect - again and again.

You may need to do some mod_rewriting for other purposes, but you do not need this code (or any other) in order to achieve what you said you wanted.

Jim

g1smd

7:55 pm on Mar 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If all of your content is available at three different URLs, then you'll end up with many indexing and ranking problems.

The whole idea is that any page of a site should be indexed under only one URL. The redirect to the canonical URL fixes that.