SiteKickr Web Development

Using redirects to avoid duplicate pages

The issue here is that search engines consider the following two locations as distinct pages:

http://www.mysite.com/products

http://www.mysite.com/products/

In the case above, the solution is simple and many posts offer such a solution to add a slash to the end of the url. But, what happens when you have the following?

http://www.mysite.com/page-without-extension

This is an actual page (not a folder or directory) which simply doesn't have an extension (common in many Content Management Systems). Your global redirect commands will force a redirect to the following, which would return a 404.

http://www.mysite.com/page-without-extension/

In this case, we'll want to specify manually which locations should be given "the slash treatment". Note, directives below are for the Apache web server (you can place these in a virtual host stanza, or in your .htaccess file)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} ^/(products|services|about|contact)
RewriteRule (.*) http://www.mysite.com$1/ [R=301,L]