Hi, in my configuration, has as DirectoryIndex this parameter: - DirectoryIndex index.html index.htm index.php If in the root virtualhost Directory, I set a redirect via htaccess and are present more index file, Rewite Rule: RewriteCond %{REQUEST_URI} !^/mysite RewriteRule ^(.*)$ site/$1 [L] Folder List: -rwxr-xr-x 1 18107657 users 1098 Aug 28 12:44 index.html -rwxr-xr-x 1 18107657 users 1094 Nov 5 2008 index.php drwxr-xr-x 16 18107657 users 2048 Mar 7 21:27 mysite when start appling rule, it's also passed as DirectoryIndex say: ex: http://mysite/ is redirected to http://mysite/mysite/index.html but in the folder if not exists, has a 404 error code.
can you attach rewrite:trace8 logs?
[rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] strip per-dir prefix: /web/htdocs/www.arubaphpini.it/home/ -> [rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] applying pattern '^(.*)$' to uri '' [rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] RewriteCond: input='/' pattern='!^/joo5' => matched [rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] rewrite '' -> 'joo5/' [rid#1ac22a0/initial] discarding query string [rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] add per-dir prefix: joo5/ -> /web/htdocs/www.arubaphpini.it/home/joo5/ [rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] strip document_root prefix: /web/htdocs/www.arubaphpini.it/home/joo5/ -> /joo5/ [rid#1ac22a0/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] internal redirect with /joo5/ [INTERNAL REDIRECT] [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] strip per-dir prefix: /web/htdocs/www.arubaphpini.it/home/index.html -> index.html [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] applying pattern '^(.*)$' to uri 'index.html' [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] RewriteCond: input='/index.html' pattern='!^/joo5' => matched [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] rewrite 'index.html' -> 'joo5/index.html' [rid#1ada480/subreq] discarding query string [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] add per-dir prefix: joo5/index.html -> /web/htdocs/www.arubaphpini.it/home/joo5/index.html [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] strip document_root prefix: /web/htdocs/www.arubaphpini.it/home/joo5/index.html -> /joo5/index.html [rid#1ada480/subreq] [perdir /web/htdocs/www.arubaphpini.it/home/] internal redirect with /joo5/index.html [INTERNAL REDIRECT] [rid#1ade6f0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] strip per-dir prefix: /web/htdocs/www.arubaphpini.it/home/joo5/index.html -> joo5/index.html [rid#1ade6f0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] applying pattern '^(.*)$' to uri 'joo5/index.html' [rid#1ade6f0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] RewriteCond: input='/joo5/index.html' pattern='!^/joo5' => not-matched [rid#1ade6f0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] pass through /web/htdocs/www.arubaphpini.it/home/joo5/index.html [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] strip per-dir prefix: /web/htdocs/www.arubaphpini.it/home/favicon.ico -> favicon.ico [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] applying pattern '^(.*)$' to uri 'favicon.ico' [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] RewriteCond: input='/favicon.ico' pattern='!^/joo5' => matched [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] rewrite 'favicon.ico' -> 'joo5/favicon.ico' [rid#1ace420/initial] discarding query string [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] add per-dir prefix: joo5/favicon.ico -> /web/htdocs/www.arubaphpini.it/home/joo5/favicon.ico [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] strip document_root prefix: /web/htdocs/www.arubaphpini.it/home/joo5/favicon.ico -> /joo5/favicon.ico [rid#1ace420/initial] [perdir /web/htdocs/www.arubaphpini.it/home/] internal redirect with /joo5/favicon.ico [INTERNAL REDIRECT] [rid#1ae4de0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] strip per-dir prefix: /web/htdocs/www.arubaphpini.it/home/joo5/favicon.ico -> joo5/favicon.ico [rid#1ae4de0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] applying pattern '^(.*)$' to uri 'joo5/favicon.ico' [rid#1ae4de0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] RewriteCond: input='/joo5/favicon.ico' pattern='!^/joo5' => not-matched [rid#1ae4de0/initial/redir#1] [perdir /web/htdocs/www.arubaphpini.it/home/] pass through /web/htdocs/www.arubaphpini.it/home/joo5/favicon.ico
In htaccess, you're implicitly matching against the filename that will be served, and mod_dir sets up the internal filename to point to the matching DirectoryIndex. You'll have to account for this in your rules, by looking at REQUEST_URI or skipping subrequests w/ the [NS] flag.
Sorry but I do not understand! In Apache 2.2 the same configuration works properly. But with Apache 2.4, priority is given to the DirectoryIndex than rewriting rules. Another example: RewriteEngine On RewriteRule ^ securecode.png captcha / code.php [L] RewriteRule ^ (. *) \ / ([0-9] *) \ / (. *) $ Template.php? Param = $ 1 & page = $ 2 & other = $ 3 [L] RewriteRule ^ (. *) \ / (Page =) ([0-9] *) $ template.php? Page = $ 1 & page = $ 3 [L] RewriteRule ^ (. *). Htm $ template.php? Page = $ 1 [QSA] RewriteRule ^ $ template.php [L] and I foder such an index.php file, the rewrite is not considered and you will see the contents of the file index.php [Tue Oct 02 12:03:47.206423 2012] [authz_core:debug] [pid 24027:tid 139640557938432] mod_authz_core.c(802): [client 46.37.0.11:16001] AH01626: authorization result of Require all granted: granted [Tue Oct 02 12:03:47.206465 2012] [authz_core:debug] [pid 24027:tid 139640557938432] mod_authz_core.c(802): [client 46.37.0.11:16001] AH01626: authorization result of <RequireAny>: granted [Tue Oct 02 12:03:47.207751 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> [Tue Oct 02 12:03:47.207772 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^securecode.png' to uri '' [Tue Oct 02 12:03:47.207783 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> [Tue Oct 02 12:03:47.207792 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/([0-9]*)\\/(.*)$' to uri '' [Tue Oct 02 12:03:47.207801 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> [Tue Oct 02 12:03:47.207810 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/(page=)([0-9]*)$' to uri '' [Tue Oct 02 12:03:47.207818 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> [Tue Oct 02 12:03:47.207826 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*).htm$' to uri '' [Tue Oct 02 12:03:47.207835 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> [Tue Oct 02 12:03:47.207861 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^$' to uri '' [Tue Oct 02 12:03:47.207874 2012] [rewrite:trace2] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] rewrite '' -> 'template.php' [Tue Oct 02 12:03:47.207884 2012] [rewrite:trace3] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] add per-dir prefix: template.php -> /web/htdocs/www.rosinicornici.it/home/template.php [Tue Oct 02 12:03:47.207899 2012] [rewrite:trace2] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip document_root prefix: /web/htdocs/www.rosinicornici.it/home/template.php -> /template.php [Tue Oct 02 12:03:47.207908 2012] [rewrite:trace1] [pid 24027:tid 139640557938432] mod_rewrite.c(467): [client 46.37.0.11:16001] 46.37.0.11 - - [www.rosinicornici.it/sid#1c117c0][rid#7f0070002970/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] internal redirect with /template.php [INTERNAL REDIRECT] sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^securecode.png' to uri '' sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/([0-9]*)\\/(.*)$' to uri '' sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/(page=)([0-9]*)$' to uri '' sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*).htm$' to uri '' sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/ -> sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^$' to uri '' sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] rewrite '' -> 'template.php' sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] add per-dir prefix: template.php -> /web/htdocs/www.rosinicornici.it/home/template.php sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip document_root prefix: /web/htdocs/www.rosinicornici.it/home/template.php -> /template.php sid#1c117c0][rid#7f0070028da0/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] internal redirect with /template.php [INTERNAL REDIRECT] sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.html -> index.html sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^securecode.png' to uri 'index.html' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.html -> index.html sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/([0-9]*)\\/(.*)$' to uri 'index.html' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.html -> index.html sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/(page=)([0-9]*)$' to uri 'index.html' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.html -> index.html sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*).htm$' to uri 'index.html' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.html -> index.html sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^$' to uri 'index.html' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] pass through /web/htdocs/www.rosinicornici.it/home/index.html sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.htm -> index.htm sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^securecode.png' to uri 'index.htm' sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.htm -> index.htm sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/([0-9]*)\\/(.*)$' to uri 'index.htm' sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.htm -> index.htm sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/(page=)([0-9]*)$' to uri 'index.htm' sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.htm -> index.htm sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*).htm$' to uri 'index.htm' sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] rewrite 'index.htm' -> 'template.php?pagina=index' sid#1c117c0][rid#7f0070020d60/subreq] split uri=template.php?pagina=index -> uri=template.php, args=pagina=index sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] add per-dir prefix: template.php -> /web/htdocs/www.rosinicornici.it/home/template.php sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/template.php -> template.php sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^$' to uri 'template.php' sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip document_root prefix: /web/htdocs/www.rosinicornici.it/home/template.php -> /template.php sid#1c117c0][rid#7f0070020d60/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] internal redirect with /template.php [INTERNAL REDIRECT] sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.php -> index.php sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^securecode.png' to uri 'index.php' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.php -> index.php sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/([0-9]*)\\/(.*)$' to uri 'index.php' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.php -> index.php sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/(page=)([0-9]*)$' to uri 'index.php' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.php -> index.php sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*).htm$' to uri 'index.php' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/index.php -> index.php sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^$' to uri 'index.php' sid#1c117c0][rid#7f0070022d70/subreq] [perdir /web/htdocs/www.rosinicornici.it/home/] pass through /web/htdocs/www.rosinicornici.it/home/index.php sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/favicon.ico -> favicon.ico sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^securecode.png' to uri 'favicon.ico' sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/favicon.ico -> favicon.ico sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/([0-9]*)\\/(.*)$' to uri 'favicon.ico' sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/favicon.ico -> favicon.ico sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*)\\/(page=)([0-9]*)$' to uri 'favicon.ico' sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/favicon.ico -> favicon.ico sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^(.*).htm$' to uri 'favicon.ico' sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] strip per-dir prefix: /web/htdocs/www.rosinicornici.it/home/favicon.ico -> favicon.ico sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] applying pattern '^$' to uri 'favicon.ico' sid#1c117c0][rid#7f0070004980/initial] [perdir /web/htdocs/www.rosinicornici.it/home/] pass through /web/htdocs/www.rosinicornici.it/home/favicon.ico
I have the same problem with mod_rewrite + mod_dir (also similar bug https://issues.apache.org/bugzilla/show_bug.cgi?id=53929). A mod_dir call undesirable subrequest and override a previous rewrited URL. .htaccess: DirectoryIndex index1.html index2.html RewriteEngine On RewriteRule !\.html$ /index3.html [L] URL: http://localhost/ Bad result (Apache 2.4.3, 2.4.4): index1.html or index2.html Expected result (Apache 2.2.22): index3.html Rewritelog: [Sat Feb 23 19:46:28.683232 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid #7fe007bdda60][rid#7fe007acc0a0/initial] [perdir /var/www/default/] strip per-dir prefix: /var/www/default/ -> [Sat Feb 23 19:46:28.683286 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007acc0a0/initial] [perdir /var/www/default/] applying pattern '\\.html$' to uri '' [Sat Feb 23 19:46:28.683307 2013] [rewrite:trace2] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007acc0a0/initial] [perdir /var/www/default/] rewrite '' -> 'index3.html' [Sat Feb 23 19:46:28.683324 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007acc0a0/initial] [perdir /var/www/default/] add per-dir prefix: index3.html -> /var/www/default/index3.html [Sat Feb 23 19:46:28.683342 2013] [rewrite:trace2] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007acc0a0/initial] [perdir /var/www/default/] strip document_root prefix: /var/www/default/index3.html -> /index3.html [Sat Feb 23 19:46:28.683351 2013] [rewrite:trace1] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007acc0a0/initial] [perdir /var/www/default/] internal redirect with /index3.html [INTERNAL REDIRECT] [Sat Feb 23 19:46:28.683403 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007ac10a0/subreq] [perdir /var/www/default/] strip per-dir prefix: /var/www/default/index1.html -> index1.html [Sat Feb 23 19:46:28.683421 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007ac10a0/subreq] [perdir /var/www/default/] applying pattern '\\.html$' to uri 'index1.html' [Sat Feb 23 19:46:28.683432 2013] [rewrite:trace1] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007ac10a0/subreq] [perdir /var/www/default/] pass through /var/www/default/index1.html [Sat Feb 23 19:46:28.683458 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007ac10a0/subreq] [perdir /var/www/default/] strip per-dir prefix: /var/www/default/index2.html -> index2.html [Sat Feb 23 19:46:28.683472 2013] [rewrite:trace3] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007ac10a0/subreq] [perdir /var/www/default/] applying pattern '\\.html$' to uri 'index2.html' [Sat Feb 23 19:46:28.683487 2013] [rewrite:trace1] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid [Sat Feb 23 19:46:28.683487 2013] [rewrite:trace1] [pid 28647:tid 140599957112576] mod_rewrite.c(468): [client 127.0.0.1:8813] 127.0.0.1 - - [localhost/sid#7fe007bdda60][rid#7fe007ac10a0/subreq] [perdir /var/www/default/] pass through /var/www/default/index2.html
Created attachment 29989 [details] first revision of patch (53794 and 53929)
I discovered that bug is appeared in revision 233369 (http://svn.apache.org/viewvc?view=revision&revision=233369) and I am offering a patch. Please, review needed.
Sorry this went unacknowledged. This issue was a regression in 2.4.x but was fixed in 2.4.8 with a pair of changes *) mod_dir: Don't search for a DirectoryIndex or DirectorySlash on a URL that was just rewritten by mod_rewrite. PR53929. [Eric Covener] *) mod_dir: Add DirectoryCheckHandler to allow a 2.2-like behavior, skipping execution when a handler is already set. PR53929. [Eric Covener]