Skip to content

Instantly share code, notes, and snippets.

@matteocaberlotto
Last active October 4, 2015 13:58
Show Gist options
  • Save matteocaberlotto/2649762 to your computer and use it in GitHub Desktop.
Save matteocaberlotto/2649762 to your computer and use it in GitHub Desktop.
an .htaccess example
AuthType Basic
AuthName "Restricted area"
AuthUserFile /path/to/httpdocs/web/.htpasswd
Require valid-user
Options +FollowSymLinks +ExecCGI
# video types
AddType video/mp4 .mp4
AddType video/ogg .ogv
AddType video/webm .webm
AddType video/x-m4v .m4v
AddType video/ogg .ogg
# disable ETags when using mod_headers
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
<IfModule mod_deflate.c>
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
# Adding by mimetype sample
# AddOutputFilterByType DEFLATE text/html text/plain text/css
<IfModule mod_headers.c>
# properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 7 days"
ExpiresByType image/gif "access plus 7 days"
ExpiresByType image/jpeg "access plus 7 days"
ExpiresByType image/png "access plus 7 days"
ExpiresByType text/html "access plus 7 days"
ExpiresByType text/css "access plus 7 days"
ExpiresByType text/javascript "access plus 7 days"
ExpiresByType application/javascript "access plus 7 days"
ExpiresByType application/x-javascript "access plus 7 days"
ExpiresByType text/plain "access plus 7 days"
# this is official microsoft standard
ExpiresByType image/vnd.microsoft.icon "access plus 7 days"
# this actually works
# (define a standard and get ignored. now i hope u get how it feels)
ExpiresByType image/x-icon "access plus 7 days"
</IfModule>
<IfModule mod_headers.c>
<filesMatch "\.(webm|mp4)$">
Header set Status "HTTP/1.1 206 Partial Content"
</filesMatch>
</IfModule>
<FilesMatch .mp4$>
SetEnv no-gzip 1
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
#<IfModule mod_vhost_alias.c>
# RewriteBase /
#</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment