Skip to content

Instantly share code, notes, and snippets.

@swooningfish
Last active September 27, 2015 16:38
Show Gist options
  • Save swooningfish/1300033 to your computer and use it in GitHub Desktop.
Save swooningfish/1300033 to your computer and use it in GitHub Desktop.
.htaccess file for apache2 and kohana
# Turn on URL rewriting
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_ADDR} !^192\.168\.0\.7
RewriteCond %{HTTP_HOST} ^(www.example\.com)(:80)?
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
# Rewrite all query strings to query helper
RewriteRule ^query/(.*)/(.*)$ query.php?$1=$2 [L]
FileETag none
php_value upload_max_filesize 20M
php_value post_max_size 20M
#php_value max_execution_time 0
#php_value max_input_time 0
#php_value memory_limit 1256M
# PIE.htc
AddType text/x-component .htc
php_value include_path '/'
php_value output_buffering Off
php_value default_charset UTF-8
php_value register_globals off
php_flag magic_quotes_gpc off
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>
<IfModule mod_expires.c>
<IfModule mod_headers.c>
Header unset Pragma
FileETag None
Header unset ETag
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 year (forever?)
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|gif|jpg|jpeg|png|swf)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</FilesMatch>
## Set up 31 days caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A2678400
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
### Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment