Bug 1210091

Summary: mod_rewrite bug - not actually rewriting
Product: Red Hat Enterprise Linux 7 Reporter: mcin <mcinp>
Component: httpdAssignee: Luboš Uhliarik <luhliari>
Status: CLOSED ERRATA QA Contact: Martin Frodl <mfrodl>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.1CC: isenfeld, jkaluza, jorton, mcinp
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 04:37:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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