Jump to content

Rewrite directory to subdomain to avoid duplicate content


Kerosene

Recommended Posts

Both these urls point to the same page:

www.domain.com/subdomain/whatever+search+term
subdomain.com/whatever+search+term

 

Can anyone suggest an elegant way to make it so:

www.domain.com/subdomain/whatever+search+term
301s to:
subdomain.com/whatever+search+term

 

I've cut and pasted a few things together and this works.

But I have no idea about mod_rewrite, and would apprecite if someone could tidy it up a bit.

This is the htaccess in my domain.com/subdomain directory...

Options +FollowSymLinks
RewriteEngine On

#this makes the url prettier - and works fine
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteRule ^([^/\.]+)/?$ index.php?s=$1 [QSA,L]

#this is the directory>subdomain stuff i'm not so sure about, it does work though
RewriteRule !\..{3,4}$ - [C]
RewriteCond %{HTTP_HOST} !^subdomain
RewriteCond %{REQUEST_URI} !^.*/$
RewriteRule ^(.+)$ http://subdomain.domain.com/ [R=301,L]

RewriteCond %{HTTP_HOST} !^subdomain
RewriteRule ^(.*)$ http://subdomain.domain.com/$1 [R]

 

Can anyone clean this up a bit? Or at least let me know if it's safe to use (in terms of SEO)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.