URL with trailing slash

Some people prefer use trailing slash for urls for example http://example.com/something/ instead of http://example.com/something, actually, according to RFC 3986 it does make a difference. Any two URLs are not a character-by-character match (ignoring URL encoding which does not apply in this case) are considered to indicate different resources. This means that client agents such as Google, Yahoo, MSN, and all other search engines, crawlers, systems and all browsers are violating the specification if they assume the two URLs are the same.

Well, to avoid this problem we can follow this steps to modify the .htaccess:

# Custom Fix
# Only if url does not contain already a trailing slash "/" or a file extension ".xxxxx" at the end
# trailing slash fix
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ http://example.com/$1/ [R=301,L]

0
Your rating: None

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: [code], [blockcode], [as], [as3], [css], [drupal5], [drupal6], [html], [java], [javascript], [mysql], [php], [xml].
  • You may quote other posts using [quote] tags.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.