5ubliminal@twitter

To Slash or Not To Slash - This is the Question?! : 5ubliminal's TellinYa

<a href="http://www.tellinya.com/art2/132/">To Slash or Not To Slash - This is the Question?! : 5ubliminal's TellinYa</a>
5ubliminal's YAMS
The Trailing Slash Duplicate Content Issue

As many might notice many pages are indexed by Google in the following form:

http://www.site.com/level1/level2/level3 and consideres the next a different page: http://www.site.com/level1/level2/level3/

And a sample has been posted on Matt Cutts' blog pointing to this Google search of hit own site :) ! This is 13th September 2007. This issue might be (have been) addressed by Google.

Matt Cutts has Duplicate Pages :)

Yahoo! has no problem as it strips the trailing slash by default. If you want to fix this for Google read on.

The .htaccess Fix 1:

This fix will add a slash to all paths where no extension is found!

#-- Fix not ending in /
#Check if does no end in slash
RewriteCond %{REQUEST_URI} [^\/]$
#Next line checks for extensions in the last segment /*[end]
RewriteCond %{REQUEST_URI} !\.([a-z0-9]+)$
#If it has no extension 301 to the slash version
RewriteRule ^(.*)$ \/$1\/ [R=301,L]

The .htaccess Fix 2:

This fix will remove the trailing slash from all paths where it is found!

#-- Slash ending /
#Check if does no end in slash
RewriteCond %{REQUEST_URI} [\/]$
#Slash the slash and 301 to the non-slash version
RewriteRule ^(.*)[\/]$ \/$1 [R=301,L]

Hope this helps you but make sure your implmentations do not make paths considered as files with no extension as this might break your sites. Other .htaccess rules migh be overridden by this is you rely on any of the slahs non-slash forms of URL. Caution!

5ubliminal's TellinYa.com SEM & SEO Blog © 2007 - All rights reserved unless mentioned otherwise .
Rendered On : [Saturday, 13 March, 2010 - 10:21:28 GMT]   No Ajax / Flash Used Here
" To Slash or Not To Slash - This is the Question?! : 5ubliminal's TellinYa "
Close
Tellinya.com is relocating to blog.5ubliminal.com. This blog is no longer maintained and comments are no longer accepted / answered.