ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

.htaccess Wrappers with PHP

(Page 3 out of 6)

The same basic formula can be applied again for other uses -- HTTP compression, for example. This was an idea that used to be impractical because computers ran at slower speeds, and is now obsolete because of broadband technologies (DSL and cable).

It works like this: when an HTML page is loaded, the web server instead gives the visitor a zipped or compressed version of that page. The visitor downloads that file, which of course takes up less space than the real thing and downloads in less time, then unzips it and displays the original page.

In this age of lighting fast DSL lines, there's almost no noticeable difference. However, if you have a site that hosts large files whose audience is mostly dialup users, it might be something to look into.

Make a new folder called "compress". Create your htaccess file again, just as before, but set the extensions to include .htm, .html, and .txt. (The group name, folder name, and script name have nothing to do with one another, you can name any of these whatever you like -- I just like things to match.)

Our wrapper script for this should be called "compress.php". That's what I'm naming mine. This means the htaccess file you have should look as follows:

AddHandler compress .html
AddHandler compress .htm
AddHandler compress .txt

Action compress /compress/compress.php

If our wrapper were simply going to pass through the file (in other words, just read its contents into a variable and display it), our handler script would look like this:

« Previous: Tortilla Wrap
Next: "Gift Wrapping" Your Output »



Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. Introduction
  2. Tortilla Wrap
  3. Shrink-Wrap
  4. "Gift Wrapping" Your Output
  5. The best thing since bubble wrap
  6. The Wrap-Up
Bookmark Article
Download Article
PDF
Download this article as a PDF file