Last active
August 17, 2018 14:02
-
-
Save celsowhite/5ee2e102b1f2cf0025ab4693d3dff60c to your computer and use it in GitHub Desktop.
Common rewrites I use in projects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force all www to redirect to non-www | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^www\.example\.com$ | |
RewriteRule ^/?$ "https\:\/\/example\.com\/" [R=301,L] | |
# Force all http to redirect to https | |
RewriteEngine On | |
RewriteCond %{HTTPS} off | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Single page app rewrite on Apache servers. Ensures routing system works properly. | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^index\.html$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.html [L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment