Could someone please explain how to alter the .htaccess file to force a trailing slash on the end of permalink WordPress page URLs that use the page slug? (eg ww*.domain.com/page-slug/) Yahoo is indexing all default page URLs, that are linked to with a trailing slash, without the trailing slash (eg ww*.domain.com/page-slug).
This means that someone who finds a WordPress page in Yahoo and decides to link to it could do so without the trailing slash. Then if Google follows that link it will likely index both versions - I am seeing this happening and it is not a good thing.
higher-logic
Member
Posted 5 years ago #
Ok, this is really late, but I might as well answer it. Add the following to your .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [QSA,L,R=301]
I was looking for something like this as well. Thanks.
What about redirecting from www to non-www domain?
How would you change this rule so that it doesn't apply to files with .html extension?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [QSA,L,R=301]
Thanks.