URLs without Trailing Slash – Kill Performance – ~5 sec per page load – htaccess help?


Did you know the absence of a trailing slash costs about 5 seconds on page load time?

Well neither did I…. I’m running multi-site with child blogs. Links without the trailing slash take about 5 seconds extra to load from the redirect.

I can’t seem to get any .htaccess fixes to work except for a simple redirect. This one works fine:

Redirect 301 /foobar /blog/pemf/

But more complex rules don’t:

Here are two I’ve tried. Here is an article on the topic.

# Doesn’t seem to work (preferred)

RewriteEngine On

RewriteBase /

RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([a-zA-Z0-9]+)

RewriteRule ^([a-zA-Z0-9]+)$ /%1/? [R=301,L]

# And niether does this one

# 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

# This one can’t work because I have other subdomain sites running too (just a test though)

RewriteRule (.*) http://whnlive.com/$1/ [R=301,L]