htaccess wrapper with PHP
Translation of the original in Catalan. Read it in: CatalàCastellano
As a complement to the previous article, I add this document that I came across some time ago. It is about implementing a wrapper using the properties of the .htaccess file and using PHP as the processing engine. First of all and as a quick definition for those who don't know, a wrapper is like a program that acts by intervening in some process normally to modify its usual behavior.
Well, with this document HTACCESS Wrappers With PHP ( local ) you can learn how to use PHP as a wrapper for the files that are served in apache. So in this document we can find, as an example, how to do the following:
- Add headers and footers to .htm and .html files without having to touch the code of the source files
- How to compress the .htm, .html and .txt files with gzip just before they are sent over the network, very useful if the client or the server have little bandwidth and we have somewhat large text documents, we can save more than 50% of the bandwidth we are using
- Finally it explains how to add a watermark to the images of our site. So we don't have to waste hours and hours modifying the images one by one
As for the last point, if you don't have much CPU or the server is very busy, what I recommend you do instead of applying what is explained here is to use what I explained in: Mini-guide on how to use imagemagick.
Between this item and the previous one, I imagine you have already realized the great power that the .htaccess file has, you also have to remember that all the configurations that are discussed you can apply directly to the general apache configuration files.