Created
January 22, 2014 14:15
-
-
Save azhawkes/8559395 to your computer and use it in GitHub Desktop.
Apache mod_rewrite config to treat requests for /something as /something.html behind the scenes. Using this for a static Jekyll site because I don't want the .html extensions visible to end users.
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
RewriteEngine on | |
# Automatically rewrite /something -> something.html | |
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d | |
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.html -f | |
RewriteRule /(.*)$ /$1.html [L] | |
# Strip off .html extensions from the request and redirect | |
RewriteCond %{REQUEST_URI} ^(.+)\.html$ | |
RewriteRule /(.*)\.html$ /$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment