brandonhimpfen/web-starter-kit/master/dist/.htaccess - Htaccess File


# .htaccess #

# CORS enabled image

<IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
        <FilesMatch ".(cur|gif|ico|jpe?g|png|svgz?|webp)$">
            SetEnvIf Origin ":" IS_CORS
            Header set Access-Control-Allow-Origin "*" env=IS_CORS

# Web fonts access

<IfModule mod_headers.c>
    <FilesMatch ".(ttf|otf|eot|woff)$">
        Header set Access-Control-Allow-Origin "*"

# Custom error pages

ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

# UTF-8 encoding

AddDefaultCharset utf-8

# URL Rewriting

# Delete this line and uncomment the lines below to get started with URL rewriting
# <IfModule mod_rewrite.c>
#     Options +FollowSymlinks
#     RewriteEngine On
# </IfModule>

# Stop directory listing

<IfModule mod_autoindex.c>
    Options -Indexes

# Block access to backup files and original (source) files

<FilesMatch "(^#.*#|.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op])|~)$">
order allow,deny
deny from all

# Enable gzip

<ifModule mod_gzip.c> 
mod_gzip_on Yes 
mod_gzip_dechunk Yes 
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ 
mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* 
mod_gzip_item_include mime ^application/x-javascript.* 
mod_gzip_item_exclude mime ^image/.* 
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 

# Enable deflate

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

# Leverage browser caching, as defined by Google PageSpeed

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"

On Github License


Download PDF of Htaccess file
DEFLATE, no-gzip