Last active
December 18, 2015 01:39
-
-
Save ryanbattles/5705281 to your computer and use it in GitHub Desktop.
Statamic .htaccess
This file contains 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 | |
# secure site files | |
RewriteRule ^(_app) - [F,L] | |
RewriteRule ^(_config) - [F,L] | |
RewriteRule ^(_content) - [F,L] | |
RewriteRule ^(.*).yml$ - [F,L] | |
RewriteRule ^(.*).yaml$ - [F,L] | |
RewriteRule ^(.*).html$ - [F,L] | |
RewriteRule ^(.*/)?\.git+ - [F,L] | |
# remove the www | |
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] | |
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] | |
# remove the trailing slash | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} (.*)$ | |
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] | |
# remove index.php | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ /index.php [QSA,L] | |
# Simple 404 for missing files | |
<FilesMatch "\.(jpe?g|gif|png|bmp|ico)$"> | |
ErrorDocument 404 "File Not Found" | |
</FilesMatch> | |
# hide the control panel from the live site (optional) | |
Redirect 301 /example http://example.com/404 | |
# Cache Images and Fonts for 1 Year | |
<FilesMatch "\.(jpg|jpeg|png|gif|eot|woff|ttf|svg)$"> | |
Header set Cache-Control "max-age=29030400, public" | |
</FilesMatch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment