0

I am using Apache 2.4.7 on Windows (the problem seems not to be existant in Apache 2.2). I have a problem with the internal redirection to a prerendered file. The file exists on the disk, but is not output by apache.

In the vhost config I have (excerpt):

DocumentRoot "C:/xampp/htdocs/local.example.com/public/www.example.com/www"
DirectoryIndex index.html index.htm index.shtml index.php

In the .htaccess I have:

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{SERVER_NAME} ^(.*)\.example\.com$ NC]
RewriteCond %{DOCUMENT_ROOT}/static/filecache/prerendered/%1/index.html -f
RewriteRule .* /static/filecache/prerendered/%1/index.html [L]

The file C:/xampp/htdocs/local.example.com/public/www.example.com/www/static/filecache/prerendered/local/index.html exists in the filesystem. This can be seen in the log too.

When I make a request to http://local.example.com/, the following comes up in the rewrite log:

[Fri Aug 22 10:14:51.267055 2014] [rewrite:trace2] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] init rewrite engine with requested uri /
[Fri Aug 22 10:14:51.267055 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] applying pattern '^/wp-content/uploads/(.*)' to uri '/'
[Fri Aug 22 10:14:51.267055 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] applying pattern '^/wp-content/gallery/(.*)' to uri '/'
[Fri Aug 22 10:14:51.267055 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] pass through /
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] strip per-dir prefix: C:/xampp/htdocs/local.example.com/public/www.example.com/www/ -> 
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] applying pattern '.*' to uri ''
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='/' pattern='^/$' => matched
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='local.example.com' pattern='^(.*)\\.example\\.com$' [NC] => matched
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='C:/xampp/htdocs/local.example.com/public/www.example.com/www/static/filecache/prerendered/local/index.html' pattern='-f' => matched
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace2] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] rewrite '' -> '/static/filecache/prerendered/local/index.html'
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7d90360/initial] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] internal redirect with /static/filecache/prerendered/local/index.html [INTERNAL REDIRECT]



[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace2] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] init rewrite engine with requested uri /index.html
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/uploads/(.*)' to uri '/index.html'
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/gallery/(.*)' to uri '/index.html'
[Fri Aug 22 10:14:51.273055 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] pass through /index.html
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] strip per-dir prefix: C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.html -> index.html
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] applying pattern '.*' to uri 'index.html'
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='/index.html' pattern='^/$' => not-matched
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] pass through C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.html



[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace2] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] init rewrite engine with requested uri /index.htm
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/uploads/(.*)' to uri '/index.htm'
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/gallery/(.*)' to uri '/index.htm'
[Fri Aug 22 10:14:51.277056 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] pass through /index.htm
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] strip per-dir prefix: C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.htm -> index.htm
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] applying pattern '.*' to uri 'index.htm'
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='/index.htm' pattern='^/$' => not-matched
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] pass through C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.htm


[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace2] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] init rewrite engine with requested uri /index.shtml
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/uploads/(.*)' to uri '/index.shtml'
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/gallery/(.*)' to uri '/index.shtml'
[Fri Aug 22 10:14:51.289057 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] pass through /index.shtml
[Fri Aug 22 10:14:51.297058 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] strip per-dir prefix: C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.shtml -> index.shtml
[Fri Aug 22 10:14:51.297058 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] applying pattern '.*' to uri 'index.shtml'
[Fri Aug 22 10:14:51.297058 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='/index.shtml' pattern='^/$' => not-matched
[Fri Aug 22 10:14:51.297058 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] pass through C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.shtml


[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace2] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] init rewrite engine with requested uri /index.php
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/uploads/(.*)' to uri '/index.php'
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] applying pattern '^/wp-content/gallery/(.*)' to uri '/index.php'
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] pass through /index.php
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] strip per-dir prefix: C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.php -> index.php
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace3] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] applying pattern '.*' to uri 'index.php'
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace4] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] RewriteCond: input='/index.php' pattern='^/$' => not-matched
[Fri Aug 22 10:14:51.298058 2014] [rewrite:trace1] [pid 9860:tid 1684] mod_rewrite.c(468): [client ::1:57345] ::1 - - [local.example.com/sid#6f0978][rid#7da63b8/subreq] [perdir C:/xampp/htdocs/local.example.com/public/www.example.com/www/] pass through C:/xampp/htdocs/local.example.com/public/www.example.com/www/index.php

I'm wondering why apache is initializing the rewrite engine with /index.html, /index.htm, /index.shtml and /index.php, even though an internal redirect happened earlier. Shouldn't it initialize the rewrite engine in the next loop with the new path (/static/filecache/prerendered/local/index.html)? The file exists but is not output by apache. According to http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule, the path /static/... should be handled as a file-system path relative to the document root:

file-system path Designates the location on the file-system of the resource to be delivered to the client. Substitutions are only treated as a file-system path when the rule is configured in server (virtualhost) context and the first component of the path in the substitution exists in the file-system URL-path A DocumentRoot-relative path to the resource to be served. Note that mod_rewrite tries to guess whether you have specified a file-system path or a URL-path by checking to see if the first segment of the path exists at the root of the file-system. For example, if you specify a Substitution string of /www/file.html, then this will be treated as a URL-path unless a directory named www exists at the root or your file-system (or, in the case of using rewrites in a .htaccess file, relative to your document root), in which case it will be treated as a file-system path. If you wish other URL-mapping directives (such as Alias) to be applied to the resulting URL-path, use the [PT] flag as described below.

I have looked at this Mod_Rewrite unexpected behavior L flag question and answer, but I dont think that my question is explained there. If it is, I seem to be missing something.

Community
  • 1
  • 1
para
  • 684
  • 5
  • 19
  • Does `C:/xampp/htdocs/local.example.com/public/www.example.com/www/static/filecache/prerendered/local/index.html` really exist? – anubhava Aug 21 '14 at 19:23
  • Actually I have to use backslashes when opening it in an editor, but yes, the file exists there. I had attached the wrong log. I updated the original question so it contains the log where it can be seen that Apache finds the file. – para Aug 22 '14 at 08:20
  • And what happens you open this URL: `http://localhost/static/filecache/p‌​rerendered/local/index.html`? – anubhava Aug 22 '14 at 08:24
  • My server name is local.example.com, so I guess You mean, http://local.example.com/static/filecache/prerendered/local/index.html? I then recieve the correct file. :) Please note that the file is fetched correctly in Apache 2.2, but not in Apache 2.4. – para Aug 22 '14 at 08:50
  • Really weird. So Apache 2.4 gives 404 for `http://local.example.com/static/filecache/prerendered/local/index.html`? – anubhava Aug 22 '14 at 09:09
  • No, both Apache 2.2 and 2.4 fetch it correctly with that url. I meant the problem in the original question only occurs in 2.4 :( – para Aug 22 '14 at 10:07

0 Answers0