Skip to content

Instantly share code, notes, and snippets.

@NV
Created October 13, 2009 10:37
Show Gist options
  • Save NV/209141 to your computer and use it in GitHub Desktop.
Save NV/209141 to your computer and use it in GitHub Desktop.
Apache .htaccess
DirectoryIndex index.html index.htm index.xhtml index.xml index.php
AddType message/rfc822 mht
AddType application/octet-stream safariextz
AddType application/atom+xml atom
AddType application/msword doc
AddType application/opensearchdescription+xml osd
AddType application/pdf pdf
AddType application/rdf+xml rdf
AddType application/rss+xml rss
AddType application/x-gzip gz
AddType application/x-javascript js
AddType application/x-xpinstall xpi
AddType application/x-opera-uniteapplication ua
AddType application/xhtml+xml xhtml xht
AddType application/zip zip
AddType audio/mpeg mp3
AddType image/gif gif
AddType image/svg+xml svg svgz
AddType image/x-icon ico
AddType text/cache-manifest manifest
AddType text/css css
AddType text/html html htm
AddType text/x-opml opml
# Video
AddType video/ogg ogg ogv
AddType video/mp4 mp4
# Fonts
AddType application/vnd.ms-fontobject eot
AddType font/ttf ttf
AddType font/otf otf
AddType font/x-woff woff
# Encoding
AddDefaultCharset utf-8
# Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# Cache-Control
<ifmodule mod_expires.c>
ExpiresActive on
ExpiresByType application/xml "access plus 1 day"
ExpiresByType image/jpeg "access plus 3 weeks"
ExpiresByType image/png "access plus 2 weeks"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</ifmodule>
# 400 Bad Request
ErrorDocument 400 /error/400.html
# 401 Authorization Required
ErrorDocument 401 /error/401.html
# 403 Forbidden
ErrorDocument 403 /error/403.html
# 404 Not Found
ErrorDocument 404 /error/404.html
# 500 Not Found
ErrorDocument 500 /error/500.html
<FilesMatch "\.(gif|jpe?g|png|ico)$">
ErrorDocument 404 http://elv1s.ru/i/404.gif
FileETag None
</FilesMatch>
# Chrome private key
<FilesMatch "\.pem$">
order allow,deny
deny from all
</FilesMatch>
# No WWW
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=Edge" env=ie
BrowserMatch chromeframe gcf
Header append X-UA-Compatible "chrome=1" env=gcf
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment