How do I do a 301 redirect because of duplicate urls
I am currently trying to do a 301 redirect for all the pages of a site i am working on. The problem is that this url:
http://site.com/cash/
http://site.com/credit/
and
http://site.com/cash
http://site.com/credit
display the same pages
This will result in a number of duplicate URL issues and start splitting your PageRank of our SEO.
I was trying to do that on my site where all the seo points to the non-slash version
BTW I have about 90 pages that i have to change...any ideas on a good way of achieving this
How do i do a 301 redirect in the htaccess to do this on all my pages
Edit:
So to understand correctly. this will do the 301 redirect
# Remove the trailing slash
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
Rew开发者_JAVA技巧riteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]
But how does this exclude folder1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
and would i put that in the same htaccess file or create another htaccess file in the folder1 directory
You can add the following to your .htaccess
to remove the trailing slash
# Remove the trailing slash
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]
Update
You can then choose to also add www
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com$1 [R=301]
or remove it
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Rather than using a 301, you could just use a rel canonical link.
You could use <shudder> mod_rewrite instead, if it's for an Apache server... It's disasterously inefficient but probably the best option if what you're bothered about is SEO
精彩评论