Kerosene Posted June 29, 2007 Share Posted June 29, 2007 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) Link to comment https://forums.phpfreaks.com/topic/57669-rewrite-directory-to-subdomain-to-avoid-duplicate-content/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.