Skip to content

Instantly share code, notes, and snippets.

@hmngwy
Created May 19, 2015 07:50
Show Gist options
  • Save hmngwy/930b7dcd34b285f32698 to your computer and use it in GitHub Desktop.
Save hmngwy/930b7dcd34b285f32698 to your computer and use it in GitHub Desktop.
Force trailing slashes in Apache
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=proto:http]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteRule ^(.*)$ %{ENV:proto}://%{HTTP_HOST}/$1/ [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment