Quarter Life Crisis

The world according to Sven-S. Porst

« Super Size MeMainRandom Links »


484 words

Ah the joy of well-written, well-documented software. Apache, say.

For a while now I wanted to do something rather simple: Have a nice URL from my own website that gets redirected to the web site where you can order the shirts I made a while ago. Their URLs are quite I ugly and I can notoriously not remember mine. A simple problem that warrants a simple solution for sure. Well, not quite, as the URL contains something as exotic as a question mark, which led me and my seemingly simply .htaccess entry RedirectMatch /shirts/ http://www.spreadshirt.de/shop.php?sid=8699 into a jungle of server errors, broken redirections and, ultimately, frustration.

In fact, I had given up on this topic until I – for different reasons – came across Jan Schmager's web site which has a nice tutorial on RedirectMatch. This inspired me to ask him for help and fiddle with the redirection a bit more – and ultimately solved the problem.

The proper solution for my problem looks like this:

Redirect 301 /shirts http://www.spreadshirt.de/shop.php?sid=8699

Not too much different. So why did I get into this trouble. Well, I blame mod_alias documentation. It contains the statement This directive is equivalent to Redirect, but makes use of standard regular expressions[...] which has to be taken with a mine of salt – at least.

There are two major differences between Redirect and RedirectMatch that I know of now. The first is that while Redirect requires a full URL as the target of redirection, RedirectMatch will be happy with a path. Something that isn't quite clear from the documentation, and may not even be intended that way. As most of my redirections are within our server and I have to use mod_alias for lack of mod_redirect, I don't see why I should prefix every singly one of them with http://earthlingsoft.net.

Hence I started always using RedirectMatch, even when there were no regular expressions needed. Those two directives are equivalent otherwise, right? Except they aren't when it comes to 'special' characters, and this means 'special' in the realm of URLs, thus even the question mark is considered 'special'. When using Redirect your question mark will be preserved, but when using RedirectMatch it will be 'percent escaped' to %3f.

I haven't read the specification of what 'percent-escaping' means, but perhaps the function they use for doing this is simply buggy. At least when I use UnicodeChecker to make an URL percent escaped, the characters ?, & and = will not be escaped. Which makes sense.

Perhaps somebody can produce an 'explanation' for this behaviour and tell people how it's all logical if only you read the documentation and the source code. But that's most likely after I said Holy crap, go insult someone else.

The bad thing about software compared to 'real' things is that you can't kick it if it doesn't behave as you want it to.

July 21, 2004, 21:31


Comment by Jan: User icon

A computer shouldn’t require the management of a nuclear power plant. ;-)

July 28, 2004, 18:30

Add your comment

« Super Size MeMainRandom Links »

Comments on




This page

Out & About

pinboard Links


Received data seems to be invalid. The wanted file does probably not exist or the guys at last.fm changed something.