Adding Trailing Slash for Yahoo using .htaccess
-
If you don’t know what I’m talking about, then, you can probably ignore this thread. I came across some code that I thought would help some WordPress users that don’t like what Yahoo does in serps listings. Basically, Yahoo lists their links without the trailing slash. So, if someone is coming from Yahoo, they would hit example.com/directory instead of example.com/directory/. It was driving me crazy, so, I hope this helps out someone else. Drop this in your .htaccess file and change the example url.
# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) http://www.example.com/$1/ [R=301,L]Thanks to mexicoshanty via this thread.
The topic ‘Adding Trailing Slash for Yahoo using .htaccess’ is closed to new replies.