Bug 1210091 - mod_rewrite bug - not actually rewriting
Summary: mod_rewrite bug - not actually rewriting
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: httpd
Version: 7.1
Hardware: All
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Web Stack Team
QA Contact: Martin Frodl
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-08 22:09 UTC by mcin
Modified: 2016-04-18 06:35 UTC (History)
4 users (show)

Fixed In Version: httpd-2.4.6-32.el7
Doc Type: Bug Fix
Doc Text:
Cause: mod_dir did not ignore the request even when it has been already handled by mod_rewrite. Consequence: mod_dir could override mod_rewrite when handlign the request for a directory because of DirectoryIndex setting. Fix: mod_dir now ignores the request when it has been handled by mod_rewrite already. Result: mod_dir no longer overrides mod_rewrite when handling requests.
Clone Of:
Environment:
Last Closed: 2015-11-19 04:37:27 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2194 normal SHIPPED_LIVE httpd bug fix and enhancement update 2015-11-19 08:05:27 UTC
Apache Bugzilla 53929 None None None Never

Description mcin 2015-04-08 22:09:17 UTC
mod_rewrite bug that was fixed in apache 2.4.9 over a year ago is still present in 2.4.6 version of httpd included in RHEL 7.1
this is a serious bug, because it makes setting mod_rewrite rules in .htaccess impossible, although they were easy to setup in apache<2.4

steps to reproduce:

set a rule in .htaccess file like

RewriteRule ^(.*)$ index.php?page=$1 [L]

the request for '/Anything' should be rewritten to '/index.php?page=Anything', but is not

it's described in apache's bugzilla https://bz.apache.org/bugzilla/show_bug.cgi?id=53929

I'm not sure if 1180745 covers this bug too.

Comment 5 Jan Kaluža 2015-07-01 09:21:57 UTC
(In reply to mcin from comment #0)
> mod_rewrite bug that was fixed in apache 2.4.9 over a year ago is still
> present in 2.4.6 version of httpd included in RHEL 7.1
> this is a serious bug, because it makes setting mod_rewrite rules in
> .htaccess impossible, although they were easy to setup in apache<2.4
> 
> steps to reproduce:
> 
> set a rule in .htaccess file like
> 
> RewriteRule ^(.*)$ index.php?page=$1 [L]
> 
> the request for '/Anything' should be rewritten to
> '/index.php?page=Anything', but is not
> 
> it's described in apache's bugzilla
> https://bz.apache.org/bugzilla/show_bug.cgi?id=53929
> 
> I'm not sure if 1180745 covers this bug too.

Hi,

it's clear what's the issue in the upstream bug report #53929, but I'm struggling to understand your reproducer.

Just "RewriteRule ^(.*)$ index.php?page=$1 [L]" won't do what you are describing even in httpd-2.2.x imho.

It rewrites "/Anything" to "index.php?page=/Anything", but then the internal redirect happens to index.php, rewrite rule applies again and in the end you will get "index.php?page=index.php".

The upstream bug report we are going to fix in RHEL-7.2 is about RewriteRule matching the same file as DirectoryIndex (for example "index.php" or "index.html").

I presume you are hitting this issue, but you haven't provided full configuration. Is that the case?

Comment 6 mcin 2015-07-04 04:48:51 UTC
Hi, that's correct, I didn't provide full contents of .htaccess, sorry for that.
The redirect won't work without RewriteCond lines as below (it's actually full contents of .htaccess that does the trick on 2.2, but not on 2.4)

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/?page=$1 [L]

Comment 9 errata-xmlrpc 2015-11-19 04:37:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2194.html


Note You need to log in before you can comment on or make changes to this bug.