Mod_rewrite and domain aliases

Using a single web hosting account to host multiple sites

Mod_rewrite and domain aliases

Postby gimmestones » Wed Apr 04, 2007 12:10 pm

Hello,

Right now I use mod_rewrite to redirect my non-www-adress to my www-address. Is working perfectly. But...

I also have 3 domain-aliases that I want to redirect to my main-domain using mod_rewrite.
I now use the following code in my .htaccess-file:

RewriteCond %{HTTP_HOST} ^www.site-a.com$
RewriteCond %{REQUEST_URI} !^/site-b.com/
RewriteRule (.*) /site-b.com/$1

I've the following question:
My goal is that search engines (google) see the above code as a '301 redirect'. I want to prevent that search engines see the domain-aliases as duplicate content. Am I using the right code for this? Or should code like [L,R=301] be included???
gimmestones
 
Posts: 1
Joined: Wed Apr 04, 2007 10:56 am

Postby richardk » Sat Apr 07, 2007 12:46 pm

So you want to redirect the sub domains to the real URL and the address bar changes? Then you'd want to use
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Add www.
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

# Redirect siteB.com/ to domain.com/siteB.com/
RewriteCond %{HTTP_HOST} ^(www\.)?siteB\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/siteB.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 37 guests

cron