Wandering Thoughts archives


Modern versions of Apache and Redirect

Our main web server is currently running Ubuntu 8.04. For reasons beyond the scope of this entry, we want to upgrade it to Ubuntu 10.04, so today I did a test install, which wound up exploding with a bunch of log messages that looked like:

[...] .htaccess: Redirect: invalid first argument (of three)

Internet searches will give you inconclusive and somewhat confused answers; it doesn't help that Apache doesn't report a line number, and that Redirect can validly take three arguments.

What you have probably done is written a Redirect that looks like this:

Redirect /a/path http://some.where/ [L]

This is a superstition. Redirect doesn't take a flags argument at the end; only RewriteRule does. It used to be harmless to put flags on the end anyways, so people did it for various reasons (mistaken belief that it was required, laziness, forgetfulness, etc). Modern versions of Apache are more picky about Redirect directives and so choke on this with the error message you see here.

(This error is especially fun in a .htaccess, because if there are any problems with a .htaccess Apache locks you out of the directory it's in. As it happened, some of our crucial .htaccess files had this problem.)

Sidebar: the Apache versions involved

To save you looking this up: Ubuntu 10.04 has Apache 2.2.16 and Ubuntu 8.04 has Apache 2.2.8. The pickiness was apparently introduced in this change in July of 2009, and it appears that this then appeared in 2.2.12 (per the CHANGES_2.2 file, which lists this PR as one of the 2.2.12 changes). Before the change, Apache would just ignore the third argument of a three-argument Redirect if it couldn't interpret the first argument as a redirection status. After the change, it considers it an error.

Looking at the change, it's hard to criticize the Apache people for it; the previous behavior was a great way to have mistakes compound themselves.

web/ModernApacheRedirect written at 01:06:41; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.