You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Julien Etter <ju...@juno.co.uk> on 2014/10/27 12:13:11 UTC

[users@httpd] DirectoryIndex and mod_rewrite

Hello,

I am trying to get my head around a behaviour I have seen on 2.4, but not
affecting 2.2.

Has anyone seen this?

 

I am using a DirectoryIndex:

DirectoryIndex index.php

 

As well as a rewrite rule in a .htaccess file:

RewriteRule  ^$ index_download.php [L]

 

If I access the folder, the RewriteRule is not triggered because the
DirectoryIndex is now part of the URL-path, which was not the case in 2.2,
where the URL would trigger the rule.

Which change is responsible for this?

 

Furthermore, if I change it to:

RewriteRule  ^(?:|index\.php)$ index_download.php [L]

 

and enable log level2, I see the following logs, if I access the URL:

 

[Mon Oct 27 10:57:35.042219 2014] [rewrite:trace2] [pid 5960]: rewrite '' ->
'index_download.php'

[Mon Oct 27 10:57:35.042266 2014] [rewrite:trace2] [pid 5960]: strip
document_root prefix: /var/www/html/htdocs/index_download.php ->
/index_download.php

[Mon Oct 27 10:57:35.042272 2014] [rewrite:trace1] [pid 5960]: internal
redirect with /index_download.php [INTERNAL REDIRECT]

 

[Mon Oct 27 10:57:35.042601 2014] [rewrite:trace2] [pid 5960]: rewrite
'index.php' -> 'index_download.php'

[Mon Oct 27 10:57:35.042615 2014] [rewrite:trace2] [pid 5960]: strip
document_root prefix: /var/www/html/htdocs/index_download.php ->
/index_download.php

[Mon Oct 27 10:57:35.042619 2014] [rewrite:trace1] [pid 5960]: internal
redirect with /index_download.php [INTERNAL REDIRECT]

 

[Mon Oct 27 10:57:35.042981 2014] [rewrite:trace1] [pid 5960]: pass through
/var/www/html/htdocs/index_download.php

 

Why are they 2 blocks, one for '', one for 'index.php'? I would expect only
one... 

Also, it seems the one for '' does not result in any rewrite, only the
second one does.

Is this expected?

Julien Etter