[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-httpd-users
Subject:    [users@httpd] Mod_rewrite END flag does not work for directory index
From:       Joyce Babu <joyce () joycebabu ! com>
Date:       2013-07-27 11:59:39
Message-ID: CACQdstM=0YTTuzRbmeMKrp4pWq7h90VdMOd+dg4-7hcN8pZz8g () mail ! gmail ! com
[Download RAW message or body]

The END flag for mod_rewrite in Apache 2.4 does not appear to be working
correctly. I have a directory named test with a file test.html. I have
placed an .htaccess file in the directory with the following content

RewriteEngine on
RewriteRule ^test$ test.html [NC,QSA,END]
RewriteRule ^$ test.html  [NC,QSA,END]

Here is the rewrite log for the request http://localhost.dev/test/

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/ ->
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] applying pattern '^test to uri ''
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/ ->
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] applying pattern '^ to uri ''
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] rewrite '' -> 'test.html'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] add per-dir prefix: test.html ->
/var/www/vhosts/test/test.html
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] strip document_root prefix:
/var/www/vhosts/test/test.html -> /test/test.html
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir
/var/www/vhosts/test/] internal redirect with /test/test.html [INTERNAL
REDIRECT]
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/index.php
-> index.php
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] applying pattern '^test to uri 'index.php'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/index.php
-> index.php
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] applying pattern '^ to uri 'index.php'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] pass through /var/www/vhosts/test/index.php
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] strip per-dir prefix:
/var/www/vhosts/test/index.html -> index.html
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] applying pattern '^test to uri 'index.html'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] strip per-dir prefix:
/var/www/vhosts/test/index.html -> index.html
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] applying pattern '^ to uri 'index.html'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir
/var/www/vhosts/test/] pass through /var/www/vhosts/test/index.html

Why is mod_rewrite making sub requests for directory index files index.html
and index.php, when the second rule matches the request? If I set a
FallbackResource directive, then the fallback file is served, instead of
the rewritten file.

Request for http://localhost.dev/test/test works without any sub request,
as expected

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/test ->
test
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir
/var/www/vhosts/test/] applying pattern '^test to uri 'test'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir
/var/www/vhosts/test/] rewrite 'test' -> 'test.html'
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir
/var/www/vhosts/test/] add per-dir prefix: test.html ->
/var/www/vhosts/test/test.html
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir
/var/www/vhosts/test/] strip document_root prefix:
/var/www/vhosts/test/test.html -> /test/test.html
[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir
/var/www/vhosts/test/] internal redirect with /test/test.html [INTERNAL
REDIRECT]

I have tried using L and END flags, independently and together.

In 2.2 it is working, even if the FallbackResource directive is set. The
problem is only in httpd 2.4. Is this a bug?

Joyce Babu

[Attachment #3 (text/html)]

<div dir="ltr"><div><div>The END flag for mod_rewrite in Apache 2.4 does not appear \
to be working correctly. I have a directory named test with a file test.html. I have \
placed an .htaccess file in the directory with the following content<br>

<br><span style="font-family:courier new,monospace">RewriteEngine on<br>RewriteRule \
^test$ test.html [NC,QSA,END]<br>RewriteRule ^$ test.html   \
[NC,QSA,END]</span><br><br>Here is the rewrite log for the request <a \
href="http://localhost.dev/test/">http://localhost.dev/test/</a><br>

<br><span style="font-family:courier new,monospace">[...] 10.0.2.2 - - \
[localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir /var/www/vhosts/test/] strip \
per-dir prefix: /var/www/vhosts/test/ -&gt;<br>[...] 10.0.2.2 - - \
[localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir /var/www/vhosts/test/] \
applying pattern &#39;^test to uri &#39;&#39;<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir \
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/ -&gt;<br>[...] \
10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir \
/var/www/vhosts/test/] applying pattern &#39;^ to uri &#39;&#39;<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir \
/var/www/vhosts/test/] rewrite &#39;&#39; -&gt; &#39;test.html&#39;<br>[...] 10.0.2.2 \
- - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir /var/www/vhosts/test/] \
add per-dir prefix: test.html -&gt; /var/www/vhosts/test/test.html<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir \
/var/www/vhosts/test/] strip document_root prefix: /var/www/vhosts/test/test.html \
-&gt; /test/test.html<br>[...] 10.0.2.2 - - \
[localhost.dev/sid#2532c00][rid#2a56d60/initial] [perdir /var/www/vhosts/test/] \
internal redirect with /test/test.html [INTERNAL REDIRECT]<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir \
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/index.php -&gt; \
index.php<br>[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] \
[perdir /var/www/vhosts/test/] applying pattern &#39;^test to uri \
&#39;index.php&#39;<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir \
/var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/index.php -&gt; \
index.php<br>[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] \
[perdir /var/www/vhosts/test/] applying pattern &#39;^ to uri &#39;index.php&#39;<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir \
/var/www/vhosts/test/] pass through /var/www/vhosts/test/index.php<br>[...] 10.0.2.2 \
- - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir /var/www/vhosts/test/] \
strip per-dir prefix: /var/www/vhosts/test/index.html -&gt; index.html<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir \
/var/www/vhosts/test/] applying pattern &#39;^test to uri \
&#39;index.html&#39;<br>[...] 10.0.2.2 - - \
[localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir /var/www/vhosts/test/] strip \
per-dir prefix: /var/www/vhosts/test/index.html -&gt; index.html<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir \
/var/www/vhosts/test/] applying pattern &#39;^ to uri &#39;index.html&#39;<br>[...] \
10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a44060/subreq] [perdir \
/var/www/vhosts/test/] pass through /var/www/vhosts/test/index.html</span><br>

<br>Why is mod_rewrite making sub requests for directory index files index.html and \
index.php, when the second rule matches the request? If I set a FallbackResource \
directive, then the fallback file is served, instead of the rewritten file.<br>

<br>Request for <a href="http://localhost.dev/test/test">http://localhost.dev/test/test</a> \
works without any sub request, as expected<br><br><span style="font-family:courier \
new,monospace">[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] \
[perdir /var/www/vhosts/test/] strip per-dir prefix: /var/www/vhosts/test/test -&gt; \
test<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir \
/var/www/vhosts/test/] applying pattern &#39;^test to uri &#39;test&#39;<br>[...] \
10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir \
/var/www/vhosts/test/] rewrite &#39;test&#39; -&gt; &#39;test.html&#39;<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir \
/var/www/vhosts/test/] add per-dir prefix: test.html -&gt; \
/var/www/vhosts/test/test.html<br>[...] 10.0.2.2 - - \
[localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir /var/www/vhosts/test/] strip \
document_root prefix: /var/www/vhosts/test/test.html -&gt; /test/test.html<br>

[...] 10.0.2.2 - - [localhost.dev/sid#2532c00][rid#2a58b20/initial] [perdir \
/var/www/vhosts/test/] internal redirect with /test/test.html [INTERNAL \
REDIRECT]</span><br><br>I have tried using L and END flags, independently and \
together.<br>

<br></div>In 2.2 it is working, even if the FallbackResource directive is set. The \
problem is only in httpd 2.4. Is this a bug?<br><br></div>Joyce Babu<br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic