Forwarding URLs & Their Descendants - RedirectMatch & .htaccess

If you want to redirect a whole site and all descendant pages to another URL, you can put this in your .htaccess file in the root of your server:

RedirectMatch ^/ http://en.wikipedia.org/wiki/TV_Links

Took me a while to ensure not only www.blah.com and http://www.blah.com were redirected, but also blah.com and blah.com/foo/bar and so on. This technique seems to work well in these instances but I have yet to master regular expressions so if any one has any pointers on trimming the end of the URL (for example ensuring http://www.blah.com/something?glass=halfempty does not become http://www.urlforwardedto.com?glass=halfempty), I would be very greatful.

The curse of php files forcing themselves to download and not display normally on your localhost

When you want to change your PHP version (like from 4 to 5) you need to put in your local .htaccess file the line:

AddHandler application/x-httpd-php5 .php

This works fine on a web server, but when applied to your localhost it causes your browser to try to download the .php file as oppossed to display it as normal.

I went mental for a few months and completely stopped web scripting because MAMP and my localhost refused to let me see my local web pages. I thought for a while it was something to do with MIME Types, but I could find no conclusive evidence to support this.

Jay from RebuildTheRobots randomly discovered this when upgrading from PHP4 to PHP5.

Remember: Don’t despair. There is always a solution.