Skip to content

Instantly share code, notes, and snippets.

@stevenliebregt
Created December 25, 2017 18:00
Show Gist options
  • Save stevenliebregt/a841f9a63d8636d10cadb2d2e6b1fa28 to your computer and use it in GitHub Desktop.
Save stevenliebregt/a841f9a63d8636d10cadb2d2e6b1fa28 to your computer and use it in GitHub Desktop.
All in one .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Redirect to non-www
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Redirect to www
#RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Force non-ssl
#RewriteCond %{HTTPS} on
#RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Force ssl
#RewriteCond %{HTTPS} off
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect all to the index file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment