Created
August 24, 2015 07:51
-
-
Save daguilarm/e2099b1ceb8fadc30fca to your computer and use it in GitHub Desktop.
Base for .httaccess
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
<ifModule mod_headers.c> | |
Header set Connection keep-alive | |
</ifModule> | |
<IfModule mod_rewrite.c> | |
<IfModule mod_negotiation.c> | |
Options -MultiViews | |
</IfModule> | |
RewriteEngine On | |
# Redirect Trailing Slashes... | |
RewriteRule ^(.*)/$ /$1 [L,R=301] | |
# Handle Front Controller... | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^ index.php [L] | |
</IfModule> | |
# Send CORS headers if browsers request them; enabled by default for images. | |
<IfModule mod_setenvif.c> | |
<IfModule mod_headers.c> | |
# mod_headers, y u no match by Content-Type?! | |
<FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$"> | |
SetEnvIf Origin ":" IS_CORS | |
Header set Access-Control-Allow-Origin "*" env=IS_CORS | |
</FilesMatch> | |
</IfModule> | |
</IfModule> | |
# Allow access from all domains for webfonts. | |
# Alternatively you could only whitelist your | |
# subdomains like "subdomain.example.com". | |
<IfModule mod_headers.c> | |
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$"> | |
Header set Access-Control-Allow-Origin "*" | |
</FilesMatch> | |
</IfModule> | |
# Deflate files to fasten the loading | |
<IfModule mod_deflate.c> | |
SetOutputFilter DEFLATE | |
AddOutputFilterByType DEFLATE application/x-httpd-php text/html text/xml text/plain text/css text/javascript application/javascript application/x-javascript image/jpeg image/jpg image/png image/gif font/ttf font/eot font/otf | |
</IfModule> | |
<IfModule mod_headers.c> | |
# properly handle requests coming from behind proxies | |
Header append Vary User-Agent | |
</IfModule> | |
<IfModule mod_deflate.c> | |
# Properly handle old browsers that do not support compression | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
# Explicitly exclude binary files from compression just in case | |
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|pdf|swf|ico|zip|ttf|eot|svg)$ no-gzip | |
</IfModule> | |
# Protect .htaccess | |
<Files .htaccess> | |
order allow,deny | |
deny from all | |
</Files> | |
# Header Expiry | |
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|webp|swf)(\.gz)?(\?.*)?$"> | |
Header set Expires "Thu, 23 Aug 2222 00:00:00 GMT" | |
Header unset ETag | |
FileETag None | |
</FilesMatch> | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresDefault "access plus 1 year" | |
</IfModule> | |
# php compression – use with caution | |
<IfModule mod_php4.c> | |
php_value zlib.output_compression 16386 | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment