Bug #1112

Weird behaviour with mod_rewrite + mod_redirect

Added by Anonymous about 13 years ago. Updated over 11 years ago.

Target version:


I can't be sure that this is a bug so much as an undesired feature. All I know for sure is that this is not the way Apache's mod_rewrite operated. If that is any gauge to measure Lighttpd's intended functionality, then this might be important:

Imagine you have a mod_redirect set up which redirects to a slight modification of the url (not a static page). For example mod_redirect redirects to (preserving the file name and query string after the /). This mod_redirect is site-wide and should apply to ALL urls (mod_rewrited ones and "true" ones).

If you also have a mod_rewrite rule set up such as the following:
url.rewrite = ( "^/profile/(a-zA-Z{1}0-9a-zA-Z_{2,20})/?$" => "/profile.php?u=$2")

This rule is the equivalent to "Nice URLs", i.e. simply for aesthetic purposes. What ends up happening is that if you access the profile page in its rewritten form without the www., it will redirect to the destination page of the mod_rewrite.


user goes to
expected functionality is that it will forward to
what really happens is that the user ends up the ugly

I imagine that the mod_redirect engine doesn't redirect based on requested urls but rather the "true" urls. This must mean that despite url.redirect rule appearing first in the conf file, the url.rewrite is parsed and it's true destination page is passed to mod_redirect engine. Are mod_rewrite'd (abstracted) urls not processed by mod_redirect?

Hope this was explanatory enough. If this truly is a bug (and not me missing something, in which case I apologize) and things are unclear, feel free to email me for additional information/explanations.

-- me


Updated by Anonymous over 12 years ago

mod_rewrites are always processed before mod_redirects, so in your case, is first rewritten, and then redirected.

-- pratham.kumar


Updated by stbuehler over 12 years ago

  • Status changed from New to Fixed
  • Resolution set to invalid

Updated by stbuehler over 11 years ago

  • Status changed from Fixed to Invalid

Also available in: Atom