You are currently browsing all posts tagged with '.htaccess' in the JHuskisson.com post archives.
-
Force www. in your URL using .htaccess
Insert this into the top of your .htaccess file, making sure that ‘RewriteEngine On’ comes before it:
RewriteCond %{HTTP_HOST} !^www\.jhuskisson\.com [NC]
RewriteRule ^(.*)$ http://www.jhuskisson.com/$1 [R=301,L]Replace jhuskisson.com with your chosen domain and make sure if you are placing any full stops within the first line to enter a backslash before each full stop. This will prevent the code from not working.
6 Comments » -
Adding GZIP Compression To Your Site Via .htaccess
Just thought i’d post this little tidbit of code for you. Paste it into your .htaccess file and it will enable GZIP across all pages in that directory:
php_value output_handler ob_gzhandler
Hows it do it? This line of code sets the output handler, or output buffer as ob_gzhandler. This sets the ob_start as “ob_gzhandler” so the code doesn’t have to be entered. Normally you would have to enter this in the PHP to do GZIP Compression:
// In the head:
ob_start(”ob_gzhandler”);
// At the bottom:
ob_end_flush();What is GZIP? GZIP is a VERY effective way of keeping your bandwidth down when having large HTML/PHP pages. What it does, is compresses the page thats being sent to the user viewing your site, when the user recieves this compressed version of the page it uncompresses the page, and views it in the full form.
But how much does this effect the user? It doesn’t effect the user at all, except for Internet Explorer 0.01 users still on Windows 3.11 of course..
And what about my server? Once you originally implement this, yes, you will notice changes in your processors activity. But after a day or two you’ll soon see the processor levels lower.
How much of a difference does it really make? The answer, is roughly 80-90% of your raw code file being sent to the user is removed.
A good case study for this is Pixel2Life, before: 160kb file output, after: 14kb file output. This of course is brilliant for the 56kers, which alot of us forget about.
Please note GZIP does not compress images, just the code being outputted
22 Comments »


