/** Functions to add to htaccess through WordPress**/ add_action('mod_rewrite_rules', 'dooley_htaccess_rules'); function dooley_htaccess_rules( $rules ) { //echo'<pre>'.$rules.'</pre>'; $custom_rules = "\n # BEGIN Dooley Rules - See https://github.com/sergeychernyshev/.htaccess \n# -------------------------------------------------------------------------------------- \n# Compression: http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression \n# -------------------------------------------------------------------------------------- \n<IfModule mod_deflate.c> \nAddOutputFilter DEFLATE application/atom+xml \nAddOutputFilter DEFLATE application/json \nAddOutputFilter DEFLATE application/xhtml+xml \nAddOutputFilter DEFLATE application/xml \nAddOutputFilter DEFLATE text/css \nAddOutputFilter DEFLATE text/html \nAddOutputFilter DEFLATE text/plain \nAddOutputFilter DEFLATE text/x-component \nAddOutputFilter DEFLATE text/xml \n \n# The following MIME types are in the process of registration \nAddOutputFilter DEFLATE application/xslt+xml \nAddOutputFilter DEFLATE image/svg+xml \n \n# The following MIME types are NOT registered \nAddOutputFilter DEFLATE application/mathml+xml \nAddOutputFilter DEFLATE application/rss+xml \n# JavaScript has various MIME types \nAddOutputFilter DEFLATE application/javascript \nAddOutputFilter DEFLATE application/x-javascript \nAddOutputFilter DEFLATE text/ecmascript \nAddOutputFilter DEFLATE text/javascript \n \n# .ico files and other compressible images \nAddOutputFilter DEFLATE image/vnd.microsoft.icon \nAddOutputFilter DEFLATE image/x-icon \nAddOutputFilter DEFLATE image/bmp \nAddOutputFilter DEFLATE image/tiff \nAddOutputFilter DEFLATE application/pdf \n \n# compressible fonts (.woff is already compressed) \nAddOutputFilter DEFLATE font/opentype \nAddOutputFilter DEFLATE application/x-font-ttf \nAddOutputFilter DEFLATE application/vnd.ms-fontobject \n</IfModule> \n# ------------------------------------------------------------------------------------------------- \n# Browser Caching: http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching \n# -------------------------------------------------------------------------------------------------- \n<IfModule mod_expires.c> \nExpiresActive On \n \nExpiresByType application/json\"access plus 1 year\" \nExpiresByType application/pdf\"access plus 1 year\" \nExpiresByType application/x-shockwave-flash\"access plus 1 year\" \nExpiresByType image/bmp \"access plus 1 year\" \nExpiresByType image/gif \"access plus 1 year\" \nExpiresByType image/jpeg \"access plus 1 year\" \nExpiresByType image/png \"access plus 1 year\" \nExpiresByType image/svg+xml \"access plus 1 year\" \nExpiresByType image/tiff \"access plus 1 year\" \nExpiresByType image/vnd.microsoft.icon \"access plus 1 year\" \n ExpiresByType image/x-icon\"access plus 1 year\" \nExpiresByType text/css \"access plus 1 year\" \nExpiresByType video/x-flv \"access plus 1 year\" \nExpiresByType application/vnd.bw-fontobject\"access plus 1 year\" \nExpiresByType application/x-font-ttf\"access plus 1 year\" \nExpiresByType application/font-woff\"access plus 1 year\" \nExpiresByType font/opentype\"access plus 1 year\" \nExpiresByType image/webp\"access plus 1 year\" \n \n# The following MIME types are in the process of registration \nExpiresByType application/xslt+xml\"access plus 1 year\" \nExpiresByType image/svg+xml\"access plus 1 year\" \n \n# The following MIME types are NOT registered \nExpiresByType application/mathml+xml\"access plus 1 year\" \nExpiresByType application/rss+xml\"access plus 1 year\" \n \n# JavaScript has various MIME types \nExpiresByType application/x-javascript \"access plus 1 year\" \nExpiresByType application/javascript \"access plus 1 year\" \nExpiresByType text/ecmascript \"access plus 1 year\" \nExpiresByType text/javascript \"access plus 1 year\" \n</IfModule> \n# END Dooley Rules\n"; echo $custom_rules; return $custom_rules . $rules; }There you go.
Want more? Sign up for my weekly newsletter