Bug 20195 - per-dir prefix stripping broken without trailing slash
Summary: per-dir prefix stripping broken without trailing slash
Status: CLOSED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.0-HEAD
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-23 17:44 UTC by Liyang HU
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Liyang HU 2003-05-23 17:44:47 UTC
Hi,

Say I have the following in my /DocRoot/foo/.htaccess:

  RewriteRule (.*) http://another.site/$1 [last,redirect=permanent]

According to the comments around line 1940 of mod_rewrite.c, the local prefix
should be stripped from the URI before matching against the pattern. Indeed,
http://my.site/foo/bar does get redirected to http://another.site/bar . However,
if one tries to access http://my.site/foo , the string comparison in the code
fails, resulting in the full path being matched against the pattern. i.e.
http://my.site/foo is redirected to http://another.site//DocRoot/foo .

A temporary fix is to special-case this condition in the rewrite rules:

  RewriteRule /DocRoot/foo http://another.site/ [last,redirect=permanent]

though this is hardly elegant.

Thanks,
/Liyang
Comment 1 André Malo 2003-07-15 18:01:08 UTC
Fixed in 2.1 and proposed for inclusion into the 2.0 stable branch.

Thanks for your report and thanks for using Apache!