Apache Mod Rewrite does not rewrite file name - apache

i have the following problem:
On the download dialog on each browser it displays me only the dot extension filename
like .divx
But i want the full name eg
http://example.com/14558/.divx rewrites to 14558.divx and not onyly .divx
I want see on every browser dialog the number and the extension.
like 14558.divx
How i can solve this problem ??
RewriteRule ^([0-9]+)/.divx$ $1.divx
RewriteRule ^([0-9]+)/.mkv$ $1.mkv
RewriteRule ^([0-9]+)/.avi$ $1.avi
Current Configuration:
RewriteRule ^([0-9]+)/\.(divx|mkv|avi)$ /$1.$2
Rewrite Log:
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae5c7c8/initial] (3) [perdir F:/media/video_files/] add path info postfix: F:/media/video_files/29 -> F:/media/video_files/29/.mkv
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae5c7c8/initial] (3) [perdir F:/media/video_files/] strip per-dir prefix: F:/media/video_files/29/.mkv -> 29/.mkv
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae5c7c8/initial] (3) [perdir F:/media/video_files/] applying pattern '^([0-9]+)/\.(divx|mkv|avi)$' to uri '29/.mkv'
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae5c7c8/initial] (2) [perdir F:/media/video_files/] rewrite '29/.mkv' -> '/29.mkv'
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae5c7c8/initial] (1) [perdir F:/media/video_files/] internal redirect with /29.mkv [INTERNAL REDIRECT]
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae588f8/initial/redir#1] (3) [perdir F:/media/video_files/] strip per-dir prefix: F:/media/video_files/29.mkv -> 29.mkv
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae588f8/initial/redir#1] (3) [perdir F:/media/video_files/] applying pattern '^([0-9]+)/\.(divx|mkv|avi)$' to uri '29.mkv'
127.0.0.1 - - [19/Dec/2011:13:07:02 +0100] [video.local/sid#4518f8][rid#ae588f8/initial/redir#1] (1) [perdir F:/media/video_files/] pass through F:/media/video_files/29.mkv

Your rewriterules seem ok... err well maybe it's the backslash. By the way you could optimize in a nicer way (not tested):
RewriteRule ^([0-9]+)/\.(divx|mkv|avi)$ /$1.$2
But the only way to solve your problem (= show the whole filename) is to make a full redirect to a URL that has the full filename.
So in your case redirect would mean these rules:
RewriteRule ^([0-9]+)/\.(divx|mkv|avi)$ $1.$2 [QSA,R=301,L]
And that implies that the URLs like "14558.divx" and "1526.mkv" have to be valid and return the file.
Two hints:
Please try to use the RewriteLog directive: it helps you to track down such problems:
# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
My favorite tool to check for regexp:
http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)

Related

mod_rewrite END flag not working in httpd 2.4

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?
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.
It appears mod_dir does not respect the END flag set by mod_rewrite. For anyone else who is experiencing this, I was able to work around the problem with the following
RewriteEngine on
RewriteRule ^$ /test/home.php [NC,QSA,END,E=IS_DIR_INDEX:1]
FallbackResource /test/fallback.php
<If "env('IS_DIR_INDEX') == 1">
SetHandler default_handler
</If>
I hit the same problem on Apache 2.4.7 on Ubuntu and reported a bug to Apache which was confirmed and is fixed in 2.4.9, see here. For Ubuntu, there is an updated PPA here for easy upgrade. If upgrading is not possible or you don't want to compile the sources, you can use Joyce's workaround above, or the one I posted here which uses only RewriteCond and RewriteRule.

Why Apache mod_rewrite rewrites twice my URL?

I need to rewrite /admin/page/create URL to /backend/www/index.php/page/create, so I use the next Apache rewrite rule and conditions:
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !backend\/www
RewriteRule admin\/(.*)$ backend/www/index.php/$1 [NS,L]
However, examining the rewrite log, I see Apache rewrites correctly the URL, but at the end it performs an additional rewrite considering /page/create URL, which doesn't match any condition, so it fails and I receive the "No input file specified." error.
How can I prevent Apache to perform that additional rewrite? I used NS flag and RewriteCond %{IS_SUBREQ} f condition and it also performs the subrequest.
Thank you!
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (2) init rewrite engine with requested uri /admin/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (1) pass through /admin/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] add path info postfix: /home/daniloaz/dev.daniloaz.com/httpdocs/admin -> /home/daniloaz/dev.daniloaz.com/httpdocs/admin/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] strip per-dir prefix: /home/daniloaz/dev.daniloaz.com/httpdocs/admin/page/create -> admin/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] applying pattern 'admin\/(.*)$' to uri 'admin/page/create'
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (4) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] RewriteCond: input='/admin/page/create' pattern='!-f' => matched
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (4) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] RewriteCond: input='/admin/page/create' pattern='!-d' => matched
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (4) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] RewriteCond: input='/admin/page/create' pattern='!backend\/www' => matched
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (4) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] RewriteCond: input='/admin/page/create' pattern='((admin\/(.*)$)|(admin$))' => matched
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (4) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] RewriteCond: input='false' pattern='f' => matched
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (2) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] rewrite 'admin/page/create' -> 'backend/www/index.php/page/create'
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] add per-dir prefix: backend/www/index.php/page/create -> /home/daniloaz/dev.daniloaz.com/httpdocs/backend/www/index.php/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (2) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] strip document_root prefix: /home/daniloaz/dev.daniloaz.com/httpdocs/backend/www/index.php/page/create -> /backend/www/index.php/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a35d60/initial] (1) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] internal redirect with /backend/www/index.php/page/create [INTERNAL REDIRECT]
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a472f0/initial/redir#1] (2) init rewrite engine with requested uri /backend/www/index.php/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a472f0/initial/redir#1] (1) pass through /backend/www/index.php/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a472f0/initial/redir#1] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] add path info postfix: /home/daniloaz/dev.daniloaz.com/httpdocs/backend/www/index.php -> /home/daniloaz/dev.daniloaz.com/httpdocs/backend/www/index.php/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a472f0/initial/redir#1] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] strip per-dir prefix: /home/daniloaz/dev.daniloaz.com/httpdocs/backend/www/index.php/page/create -> backend/www/index.php/page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a472f0/initial/redir#1] (3) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] applying pattern 'admin\/(.*)$' to uri 'backend/www/index.php/page/create'
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a472f0/initial/redir#1] (1) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] pass through /home/daniloaz/dev.daniloaz.com/httpdocs/backend/www/index.php
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a4ce60/subreq] (2) init rewrite engine with requested uri /page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a4ce60/subreq] (1) pass through /page/create
80.29.4.44 - - [13/Jun/2013:21:40:54 +0200] [dev.daniloaz.com/sid#7f65e59b6a78][rid#7f65e5a4ce60/subreq] (1) [perdir /home/daniloaz/dev.daniloaz.com/httpdocs/] pass through /home/daniloaz/dev.daniloaz.com/httpdocs/page
Well, I finally solved this issue using a workaround. First I tried these solutions, but subrequests were performed again and again and rewriting failed as before.
With mod_rewrite, there are small differences if you put a rule in .htaccess or in global configuration (httpd.conf, Virtualhost configuration, etc.). Subrequests are one of that differences. Just place the same rule I mentioned above in Virtualhost config file instead of .htaccess and subqueries stop and everything starts working like a charm.
I recommend this useful post to fully understand the internals of mod_rewrite before trying to solve any related to it issue: http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/
I just want to drop my experience here in case somebody reaches the same point I did:
I had the same problem. I tried every single answer. Every single solution. Up to the level when I can say "I really fully understand the rewrite engine". But nothing works. My URLs were still changing and showing the query string.
In some moment I said: "This is likely improbable. Must be something else". And then I tried to get the URL with WGET instead of the browser (firefox).
I did:
wget -qSO http://MY-THING
And then I realized that NOTHING from the server said the URL I saw in the browser's address bar. And even better, NOTHING in the log file!
So... how and why does it change? The obvious answer is "the browser"
I tried another browser (chrome) and works!
So what I did was to clean the history with the "forget this site" option and everybody happy.
Now I don't know WHEN I fixed it. Might be the -Multiviews thing, or the rule's flags, or the INTERNAL REDIRECT part... I don't really know. But probably the solution wasn't there.

Conditionally redirecting traffic with mod_rewrite dependent on protocol

I've been writing a rewrite rule to try and redirect all of our traffic from mysite.com.au to www.mysite.com.au. I also need to conditionally redirect depending on SSL enabled or not.
I've hacked on a bit from askapache.com to create a variable that holds either http or https dependently. Below is the code I'm using:
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
RewriteCond %{HTTP_HOST} ^mysite\.com\.au(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ %{ENV:ps}://www.mysite.com.au/$1 [L,R=301]
This works fine for URLs with paths (e.g. mysite.com.au/foo redirects to www.mysite.com.au/foo) and does the http and https switch fine.
However when just accessing the domain (just mysite.com.au) it redirects to http://www.mysite.com.au/home/website/public_html/:/www.mysite.com.au/
I'm sure it's something very small and basic I'm missing - if someone could point it out, that'd be appreciated.
Thanks!
Andrew
I've found an answer - it's nothing like what it seems from first glance.
I turned on RewriteLog and I identified the problem. In the logs if I am using my original condition/rule and use mysite.com.au/test I see the following:
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/test -> test
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri 'test'
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/test -> test
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri 'test'
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/test -> test
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri 'test'
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (2) [perdir /home/website/public_html/] rewrite 'test' -> 'http://www.mysite.com.au/test'
10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [mysite.com.au/sid#b81d24f8][rid#b847d100/initial] (2) [perdir /home/website/public_html/] explicitly forcing redirect with http://www.mysite.com.au/test
However when I run it against just mysite.com.au I see:
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/ ->
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri ''
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/ ->
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri ''
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/ ->
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (2) [perdir /home/website/public_html/] rewrite '' -> '://www.mysite.com.au/'
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (3) [perdir /home/website/public_html/] add per-dir prefix: ://www.mysite.com.au/ -> /home/website/public_html/://www.mysite.com.au/
10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [mysite.com.au/sid#b81d24f8][rid#b845bc18/initial] (2) [perdir /home/website/public_html/] explicitly forcing redirect with http:/.makeitmine.com.au/home/website/public_html/://www.mysite.com.au/
Note that the environment variable I’m trying to set (SSL on/off) isn’t being set. As such, it’s not seeing the http/https prefix and assuming it’s a relative internal path!
When I’m trying to set the environment variable, I use the following code:
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
The RegEx of ^(.+)$ expects a minimum of 1 character, which there is not to match! I modified it as follows:
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=ps:http]
And now it matches, even on 0 characters!
Thanks again for your help, problem solved :)
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/ ->
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/ ->
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (3) [perdir /home/website/public_html/] strip per-dir prefix: /home/website/public_html/ ->
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (2) [perdir /home/website/public_html/] rewrite '' -> 'http://www.mysite.com.au/'
10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [mysite.com.au/sid#b81d24f8][rid#b8478208/initial] (2) [perdir /home/website/public_html/] explicitly forcing redirect with http://www.mysite.com.au/

Apache rewrite parses URL twice unexpectedly

I'm trying to redirect all the webpages from certain domain names to a specific web application that handles several sites.
I have my web app in a folder "skylight2" and another folder, named "testsite", with only a .htaccess file:
RewriteEngine on
RewriteRule ^(((?!skylight2).)*)$ /home/stefano/webroot_aliases/skylight2/$1/?site=testsite [QSA]
I'm using virtual roots, and my httpd-vroot.conf looks like this:
<VirtualHost *:80>
ServerName webserver
ServerAlias *.webserver
UseCanonicalName Off
VirtualDocumentRoot /home/stefano/webroot_aliases/%1
Options -Indexes FollowSymLinks -MultiViews
RewriteLog "/var/log/httpd/vroot_rewrite.log"
RewriteLogLevel 3
<Directory /home/stefano/webroot_aliases/>
Order allow,deny
Allow from all
AllowOverride FileInfo Indexes Limit Options
RewriteEngine On
RewriteBase /
</Directory>
</VirtualHost>
If I try to access testsite.webserver, I get an "object not found" error. This is my rewrite log:
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#253f320/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_aliases/testsite/articles -> /home/stefano/webroot_aliases/testsite/articles/view
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#253f320/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/articles/view -> articles/view
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#253f320/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(((?!skylight2).)*)$' to uri 'articles/view'
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#253f320/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] rewrite 'articles/view' -> '/home/stefano/webroot_aliases/skylight2/articles/view/?site=testsite'
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#253f320/initial] (3) split uri=/home/stefano/webroot_aliases/skylight2/articles/view/?site=testsite -> uri=/home/stefano/webroot_aliases/skylight2/articles/view/, args=site=testsite
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#253f320/initial] (1) [perdir /home/stefano/webroot_aliases/testsite/] internal redirect with /home/stefano/webroot_aliases/skylight2/articles/view/ [INTERNAL REDIRECT]
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2531a18/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_aliases/testsite/home -> /home/stefano/webroot_aliases/testsite/home/stefano/webroot_aliases/skylight2/articles/view/
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2531a18/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/home/stefano/webroot_aliases/skylight2/articles/view/ -> home/stefano/webroot_aliases/skylight2/articles/view/
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2531a18/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(((?!skylight2).)*)$' to uri 'home/stefano/webroot_aliases/skylight2/articles/view/'
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2531a18/initial/redir#1] (1) [perdir /home/stefano/webroot_aliases/testsite/] pass through /home/stefano/webroot_aliases/testsite/home
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#252f2a0/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/favicon.ico -> favicon.ico
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#252f2a0/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(((?!skylight2).)*)$' to uri 'favicon.ico'
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#252f2a0/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] rewrite 'favicon.ico' -> '/home/stefano/webroot_aliases/skylight2/favicon.ico/?site=testsite'
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#252f2a0/initial] (3) split uri=/home/stefano/webroot_aliases/skylight2/favicon.ico/?site=testsite -> uri=/home/stefano/webroot_aliases/skylight2/favicon.ico/, args=site=testsite
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#252f2a0/initial] (1) [perdir /home/stefano/webroot_aliases/testsite/] internal redirect with /home/stefano/webroot_aliases/skylight2/favicon.ico/ [INTERNAL REDIRECT]
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2533830/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_aliases/testsite/home -> /home/stefano/webroot_aliases/testsite/home/stefano/webroot_aliases/skylight2/favicon.ico/
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2533830/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/home/stefano/webroot_aliases/skylight2/favicon.ico/ -> home/stefano/webroot_aliases/skylight2/favicon.ico/
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2533830/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(((?!skylight2).)*)$' to uri 'home/stefano/webroot_aliases/skylight2/favicon.ico/'
127.0.0.1 - - [08/Mar/2012:07:56:23 --0600] [testsite.webserver/sid#21f2ca0][rid#2533830/initial/redir#1] (1) [perdir /home/stefano/webroot_aliases/testsite/] pass through /home/stefano/webroot_aliases/testsite/home
Apparently, the URL is parsed once (correctly), and then the second time where it's added the prefix again, resulting in an error. Unfortunately, I cannot put a [L] flag to this rule because the URL gets parsed further in the application folder.
Can anybody explain to me what is happening?
Thanks
gm
EDIT: I applied the rule:
RewriteRule ^(?!skylight2)(.*)$ skylight2/$1/?site=testsite [QSA,L]
And get this:
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_a
liases/testsite/articles -> /home/stefano/webroot_aliases/testsite/articles/view
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_al
iases/testsite/articles/view -> articles/view
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(?!skylight2)(.*)$' to uri
'articles/view'
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] rewrite 'articles/view' -> 'skylight2/articles
/view/?site=testsite'
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (3) split uri=skylight2/articles/view/?site=testsite -> uri=skylight2/articles/view/, args=site=tes
tsite
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] add per-dir prefix: skylight2/articles/view/ -
> /home/stefano/webroot_aliases/testsite/skylight2/articles/view/
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#1951280/initial] (1) [perdir /home/stefano/webroot_aliases/testsite/] internal redirect with /home/stefano/webroot_a
liases/testsite/skylight2/articles/view/ [INTERNAL REDIRECT]
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/w
ebroot_aliases/testsite/home -> /home/stefano/webroot_aliases/testsite/home/stefano/webroot_aliases/testsite/skylight2/articles/view/
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/we
broot_aliases/testsite/home/stefano/webroot_aliases/testsite/skylight2/articles/view/ -> home/stefano/webroot_aliases/testsite/skylight2/articles/view/
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(?!skylight2)(.*)$'
to uri 'home/stefano/webroot_aliases/testsite/skylight2/articles/view/'
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (2) [perdir /home/stefano/webroot_aliases/testsite/] rewrite 'home/stefano/webroot_aliases/
testsite/skylight2/articles/view/' -> 'skylight2/home/stefano/webroot_aliases/testsite/skylight2/articles/view//?site=testsite'
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (3) split uri=skylight2/home/stefano/webroot_aliases/testsite/skylight2/articles/view//?sit
e=testsite -> uri=skylight2/home/stefano/webroot_aliases/testsite/skylight2/articles/view//, args=site=testsite&site=testsite
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] add per-dir prefix: skylight2/home/ste
fano/webroot_aliases/testsite/skylight2/articles/view// -> /home/stefano/webroot_aliases/testsite/skylight2/home/stefano/webroot_aliases/testsite/skylight2/articles/view//
127.0.0.1 - - [09/Mar/2012:07:22:45 --0600] [testsite.webserver/sid#161fca0][rid#195c9e0/initial/redir#1] (1) [perdir /home/stefano/webroot_aliases/testsite/] internal redirect with /home/stefano/w
ebroot_aliases/testsite/skylight2/home/stefano/webroot_aliases/testsite/skylight2/articles/view// [INTERNAL REDIRECT]
And so on in an infinite loop.
Why does apache keep adding the path info? Neither L nor DPI flags work.
EDIT #2
Following TerryE's advice I used this config:
RewriteEngine On
RewriteBase /testsite
RewriteRule ^(?!skylight2)(.*)$ /skylight2/$1?site=testsite [QSA,L]
And got this:
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_aliases/testsite/articles -> /home/stefano/webroot_aliases/testsite/articles/view
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/articles/view -> articles/view
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(?!skylight2)(.*)$' to uri 'articles/view'
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] rewrite 'articles/view' -> '/skylight2/articles/view?site=testsite'
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (3) split uri=/skylight2/articles/view?site=testsite -> uri=/skylight2/articles/view, args=site=testsite
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] trying to replace prefix /home/stefano/webroot_aliases/testsite/ with /testsite
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#2d6a740/initial] (1) [perdir /home/stefano/webroot_aliases/testsite/] internal redirect with /skylight2/articles/view [INTERNAL REDIRECT]
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a9968/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_aliases/testsite/skylight2 -> /home/stefano/webroot_aliases/testsite/skylight2/articles/view
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a9968/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/skylight2/articles/view -> skylight2/articles/view
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a9968/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(?!skylight2)(.*)$' to uri 'skylight2/articles/view'
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a9968/initial/redir#1] (1) [perdir /home/stefano/webroot_aliases/testsite/] pass through /home/stefano/webroot_aliases/testsite/skylight2
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18b1290/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/favicon.ico -> favicon.ico
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18b1290/initial] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(?!skylight2)(.*)$' to uri 'favicon.ico'
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18b1290/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] rewrite 'favicon.ico' -> '/skylight2/favicon.ico?site=testsite'
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18b1290/initial] (3) split uri=/skylight2/favicon.ico?site=testsite -> uri=/skylight2/favicon.ico, args=site=testsite
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18b1290/initial] (2) [perdir /home/stefano/webroot_aliases/testsite/] trying to replace prefix /home/stefano/webroot_aliases/testsite/ with /testsite
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18b1290/initial] (1) [perdir /home/stefano/webroot_aliases/testsite/] internal redirect with /skylight2/favicon.ico [INTERNAL REDIRECT]
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a96f0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] add path info postfix: /home/stefano/webroot_aliases/testsite/skylight2 -> /home/stefano/webroot_aliases/testsite/skylight2/favicon.ico
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a96f0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] strip per-dir prefix: /home/stefano/webroot_aliases/testsite/skylight2/favicon.ico -> skylight2/favicon.ico
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a96f0/initial/redir#1] (3) [perdir /home/stefano/webroot_aliases/testsite/] applying pattern '^(?!skylight2)(.*)$' to uri 'skylight2/favicon.ico'
127.0.0.1 - - [10/Mar/2012:08:16:58 --0600] [testsite.webserver/sid#1575ca0][rid#18a96f0/initial/redir#1] (1) [perdir /home/stefano/webroot_aliases/testsite/] pass through /home/stefano/webroot_aliases/testsite/skylight2
Apache throws a "File does not exist: /home/stefano/webroot_aliases/testsite/skylight2" error. The correct URL should be instead /home/stefano/webroot_aliases/skylight2/articles/view.
Could it be because the VirtualDocumentRoot is set to testsite and I can't get out of it once it's set?
By the way, I'm using Apache 2.2.22.
EDIT #3
I actually solved it by placing a symlink "skylight2" in testsite, pointing to "../skylight2". thanks for the help!!
I've come across this bug before and there was an old bugrep on it which fizzled out. It can occur if you do a fall-through on a Per Directory context. But since the rewrite engine loops over the htaccess files anyway, the [L] doesn't mean last it really means "restart loop".
Next your rewrite rule is wrong since your document root is home/stefano/webroot_aliases and rule targets are in URI space not file space so your target should just be skylight2/$1/?site=testsite.
Next the Negative lookahead assertion should not be inside the (.*) loop, so try:
RewriteRule ^(?!skylight2)(.*)$ skylight2/$1/?site=testsite [QSA,L]
If this doesn't work, then append the new rewrite.log extract. Thanks.
Update following comments
The rewrite log shows a DOCROOT of /home/stefano/webroot_aliases/testsite and redirects
articles/view -> testsite/skylight2/articles/view/?site=testsite
Which fails the negative lookahead and loops again, so this is a case when you do need the leading / on the replacement string:
RewriteBase /testsite
RewriteRule ^(?!skylight2)(.*)$ /skylight2/$1/?site=testsite [QSA,L]

mod_rewrite mysterious subreq

Seems like some apache module is interfering with my request uris as it suffixes ".html" to it.
My rewrite log:
172.16.103.1 - - [08/Mar/2012:14:56:33 +0100] [www.example.org/sid#7ff723575b58][rid#7ff724b4fc58/initial] (1) pass through /folder/subfolder/
172.16.103.1 - - [08/Mar/2012:14:56:33 +0100] [www.example.org/sid#7ff723575b58][rid#7ff724b42468/subreq] (3) [perdir /srv/www/html/project/] add path info postfix: /srv/www/html/project/folder/subfolder.html -> /srv/www/html/trustedshops/folder/subfolder.html/
172.16.103.1 - - [08/Mar/2012:14:56:33 +0100] [www.example.org/sid#7ff723575b58][rid#7ff724b42468/subreq] (3) [perdir /srv/www/html/project/] strip per-dir prefix: /srv/www/html/project/folder/subfolder.html/ -> folder/subfolder.html/
This merely happens on our development servers. But It's hard do compare the whole apache config. Any ideas which module could be responsible?
Turn off MultiViews as this generates subrequests
Ditto DirectoryIndex with a list of possiblities.
Use the NS flag on your rewrite rules, or
RewriteCond %{IS_SUBREQ} t
RwriteRule ^ - [L]