Skip to content

Instantly share code, notes, and snippets.

@hitautodestruct
Created February 25, 2014 13:26
Show Gist options
  • Save hitautodestruct/9208671 to your computer and use it in GitHub Desktop.
Save hitautodestruct/9208671 to your computer and use it in GitHub Desktop.
Wordpress htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Increas php file upload to 40MB
php_value upload_max_filesize 40M
php_value post_max_size 40M
php_value max_execution_time 300
php_value max_input_time 300
# Add support for the htc mime type
AddType text/x-component .htc
# Set up caching
# http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html#Apache_htaccess_caching_code
# 1 YEAR
<filesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</filesMatch>
# 1 WEEK
<filesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
# 2 DAYS
<filesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</filesMatch>
# 1 MIN
<filesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</filesMatch>
# Add Vary Accept-Encoding
# http://stackoverflow.com/questions/3641197/how-to-specify-vary-accept-encoding-header-in-htaccess
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
# Dont gzip files that are already comprssed and media
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|mp4|avi|mp?g)$ no-gzip dont-vary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment