Skip to main content

Articles tagged with "htaccess"

Removing that pesky trailing slash

11th Nov 2010

So, it's perfectly valid to visit a site using a URL like:

http://www.google.co.uk///////////

But some pesky SEO types will complain that the site is accessible at two URLs and that you need do a 301 redirect to the canonical URL (http://www.google.co.uk/). What you want to do is remove the trailing slashes using mod rewrite.

If you really need to do this, then you can just pop the following in the .htaccess file that Drupal provides:



  # Remove multiple slashes after domain
  RewriteCond %{HTTP_HOST} !=""
  RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$
  RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]

just before the # Rewrite URLs of the form...

Read more