01324 469200
Info@portaltechnologies.uk
Gzip And Set Expiry Dates Of Files With .htaccess

We’ve been using one and one as our web host for a good few years now, we’ve got a couple of older servers which run and host quite a few older sites that were created using PHP 5. You might know that the latest versions of WordPress require at least PHP 5 to be running on your server before it will even install. here’s how i get round it..

Pretty simple it’s just the first two lines below placed in an .htacess file and uploaded in the root folder of a site. They bump up the server install from version 5 to version 6 meaning that older sites created with PHP 4 are untouched by the sly upgrade. Obviously the best practice would be to revisit these older sites and update the code accordingly but this solution solves the problem when your’re developing numerous sites rapidly.

I also add the other 2 sections to speed the site up for Google as it likes sites to run as fast as possible. Basically it Gzips the files that your serving and also sets the expiry date of all files types. When you check this in Page speed in Firebug you should notice a marked difference in your sites score. Try it out and increase the speed of your site

[php]
AddType x-mapp-php6 .php
AddHandler x-mapp-php6 .php


<IfModule mod_gzip.c>
mod_gzip_on       Yes
mod_gzip_dechunk  Yes
mod_gzip_item_include file      \.(html?|txt|css|js|php|pl|jpg|png|gif)$
mod_gzip_item_include handler   ^cgi-script$
mod_gzip_item_include mime      ^text/.*
mod_gzip_item_include mime      ^text/css*
mod_gzip_item_include mime      ^application/text-javascript.*
mod_gzip_item_exclude mime      ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>


<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 day"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/jpeg "access plus 4 weeks"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/javascript "modification plus 2 weeks"
ExpiresByType text/css "modification plus 14 days"
</ifModule>
[/php]