Project

General

Profile

Actions

Bug #1112

closed

Weird behaviour with mod_rewrite + mod_redirect

Added by Anonymous almost 17 years ago. Updated over 15 years ago.

Status:
Invalid
Priority:
Normal
Category:
mod_redirect
Target version:
ASK QUESTIONS IN Forums:

Description

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 domain.com to www.domain.com (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.

e.g.:

user goes to http://domain.com/user/user1/
expected functionality is that it will forward to http://www.domain.com/user/user1/
what really happens is that the user ends up the ugly http://www.domain.com/profile.php?u=user1

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

Actions #1

Updated by Anonymous about 16 years ago

mod_rewrites are always processed before mod_redirects, so in your case, http://domain.com/user/user1/ is first rewritten, and then redirected.

-- pratham.kumar

Actions #2

Updated by stbuehler about 16 years ago

  • Status changed from New to Fixed
  • Resolution set to invalid
Actions #3

Updated by stbuehler over 15 years ago

  • Status changed from Fixed to Invalid
Actions

Also available in: Atom