Forum Moderators: phranque

Message Too Old, No Replies

Trailing slash problem proxy->mod_rewrite vhost map

         

PeeCee

10:26 am on May 20, 2006 (gmt 0)

10+ Year Member



Hello, i'm Bas from Holland.

I'v got a problem regarding traling slashes. If i browse to [domain.ex...] it gives me the index in ~/test/ but when i browse to [domain.ex...] the proxy server gives out a 404 error.

The network is build this way:
The apache proxy (10.0.0.2) code:


<VirtualHost *>
Servername domain.ex
ProxyRequests Off
ProxyVia Off
NoCache *
ProxyPass / http://domain.ex/
ProxyPassReverse / http://domain.ex/
</VirtualHost>

The code at the proxyed server (10.0.0.5):


<VirtualHost *>
DirectoryIndex index.htm index.html index.php index.phtml

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/foo/bar/vhost.map
RewriteCond %{HTTP_HOST}!^$
RewriteCond ${lowercase:%{HTTP_HOST}¦NONE} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
</VirtualHost>

I'v been working on this problem for about 2 weeks now, i'v had all of google and this forum.

I understand mod_rewrite a bit, but i'm not an expert.

Could some one please help me, thanks :)

jdMorgan

4:23 pm on May 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bas,

Welcome to WebmasterWorld!

/dir/test/ refers to the index file, such as /dir/test/index.php, as defined by DirectoryIndex.
/dir/test refers to the extensionless file "test" in the /dir subdirectory. So 404 is the correct response if no such file exists.

Apache mod_dir usually corrects directory index requests made with missing trailing slashes, so the question is, why is mod_dir not doing its job on your server?

If mod_dir is (for some strange reason) not available, mod_negotiation could also be used.

Jim

PeeCee

5:58 pm on May 20, 2006 (gmt 0)

10+ Year Member



Mod_Dir is doing it's job, only not on this mod_rewrite vhost map.

In a normal Vhost config it does not matter if the / is there or not, but here it makes a diffrence.

I guess there should be something i'm doing wrong or i'm missing something.

jdMorgan

6:56 pm on May 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm just guessing here, but if mod_dir is loaded before mod_rewrite, it will execute after mod_rewrite (on Apache 1.x at least). In that case, you may need to add a [PT,L] flag to the rule, so that the request will be passed to mod_dir as a URL, rather than as a resolved filepath.

Jim

PeeCee

12:35 am on May 22, 2006 (gmt 0)

10+ Year Member



Thanks for putting me in the right direction.

But i found out that there where no documentroot in the vhost and UseCanonicalName where On instead of Off.

Also i changed the code a bit at the RewriteRule:
RewriteRule ^(.*)$ %1/$1

Thanks for you thinking :D