Last active
August 29, 2015 14:01
-
-
Save visualpropaganda/f1ec704153acf2468bbc to your computer and use it in GitHub Desktop.
WP: htaccess + gzip etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MAINTENANCE-PAGE REDIRECT | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REMOTE_ADDR} !^193\.158\.164\.23 | |
RewriteCond %{REQUEST_URI} !/underconstruction.html$ [NC] | |
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC] | |
RewriteRule .* /underconstruction.html [R=302,L] | |
</IfModule> | |
# END MAINTENANCE-PAGE REDIRECT | |
# 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 | |
AddDefaultCharset UTF-8 | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE text/plain | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE text/xml | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE text/javascript | |
AddOutputFilterByType DEFLATE application/xml | |
AddOutputFilterByType DEFLATE application/xhtml+xml | |
AddOutputFilterByType DEFLATE application/rss+xml | |
AddOutputFilterByType DEFLATE application/atom_xml | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/x-javascript | |
AddOutputFilterByType DEFLATE application/x-shockwave-flash | |
</IfModule> | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
# forbid double slashes in all URLs | |
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(([^/\ ]+/)*)/+([^\ ]*) | |
RewriteRule ^ /%1%3 [L,R=301] | |
</IfModule> | |
# compress | |
<IfModule mod_deflate.c> | |
<FilesMatch "\.(js|jpg|jpeg|gif|png|css|txt|html)$"> | |
ExpiresActive on | |
ExpiresDefault "access plus 1 month" | |
SetOutputFilter DEFLATE | |
</FilesMatch> | |
</IfModule> | |
<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.* | |
</IfModule> | |
# cache | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType text/css "access plus 1 month" | |
ExpiresByType text/javascript "access plus 1 month" | |
ExpiresByType text/html "access plus 1 month" | |
ExpiresByType application/javascript "access plus 1 month" | |
ExpiresByType application/x-javascript "access plus 1 month" | |
ExpiresByType application/xhtml-xml "access plus 600 seconds" | |
ExpiresByType image/gif "access plus 1 week" | |
ExpiresByType image/jpeg "access plus 1 week" | |
ExpiresByType image/png "access plus 1 week" | |
ExpiresByType image/x-icon "access plus 1 month" | |
</IfModule> | |
<ifmodule mod_headers.c> | |
<filesmatch "\\.(ico|jpe?g|png|gif|swf)$"> | |
Header set Cache-Control "max-age=2592000, public" | |
</filesmatch> | |
<filesmatch "\\.(css)$"> | |
Header set Cache-Control "max-age=604800, public" | |
</filesmatch> | |
<filesmatch "\\.(js)$"> | |
Header set Cache-Control "max-age=216000, private" | |
</filesmatch> | |
<filesmatch "\\.(x?html?|php)$"> | |
Header set Cache-Control "max-age=600, private, must-revalidate" | |
</filesmatch> | |
</ifmodule> | |
# Turn ETags Off | |
<ifmodule mod_headers.c> | |
Header unset ETag | |
Header unset Last-Modified | |
</ifmodule> | |
FileETag None | |
# PROTECT wp-config.php | |
<files wp-config.php> | |
Order deny,allow | |
deny from all | |
</files> | |
# PROTECT install.php | |
<Files install.php> | |
Order Allow,Deny | |
Deny from all | |
Satisfy all | |
</Files> | |
# Add gzip compression for javascript | |
RewriteEngine on | |
RewriteCond %{HTTP:Accept-Encoding} gzip | |
RewriteCond %{REQUEST_FILENAME}.gz -f | |
RewriteRule (.*)\.js$ $1\.js.gz [L] | |
AddType "text/javascript" .js.gz | |
AddEncoding gzip .gz | |
# Add gzip compression for css | |
RewriteEngine on | |
RewriteCond %{HTTP:Accept-Encoding} gzip | |
RewriteCond %{REQUEST_FILENAME}.gz -f | |
RewriteRule (.*)\.css$ $1\.css.gz [L] | |
AddType "text/javascript" .css.gz | |
AddEncoding gzip .gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment