Forum Moderators: coopster
this certainly isn't my code ;-) but i found the following article VERY useful:
custom error pages with php [onlamp.com]
delivering a 404 is fairly standard stuff, but it also describes a VERY easy way to deliver 301 redirects without any .htaccess and mod_rewrite voodoo.
i was just faced with the prospect of redirecting 150 pages from one domain to a new one, and i had the 301 redirect set up within 30 minutes, with no need for any mod_rewrite regex at all! (all checked with the server header checker on this site.... - all valid!)
hope this helps some people who are still rather confused by mod_rewrite ;-)
Redirect Permanent /somedir/ http://www.mysite.com/newdir/
it took me longer to find the url than to type it
[httpd.apache.org...]
we do actually have our own dedicated server!
the problem was, that when we started we had combined our spanish pages with our english pages under the .com domain. using _i and _e to differentiate between them.
so i needed some sort of mod_rewrite regex to find all files which ended in _e.htm in the docroot and in various subfolders (not all) and redirect them to our new .es domain.
i tried and failed for about 2 rather frustrating hours before realising i had bookmarked that tutorial a while ago. :)
i know andreas or jdM would have magicked all that in a couple of hard to read lines ;-)