开发者

Strange behavior change in mod_rewrite

In a .htaccess context, I have a simple rewriting rule :

RewriteEngine on
RewriteRule ^dir/([^/]+)/(.*) action/do.php?a=$1&b=$2 [L,QSA]

dir and action are in the same directory, which is also my DocumentRoot.

When accessing http://example.org/dir/a/b the request should (and was) rewritten to http://example.org/action/do.php?a=a&b=b without redirection or anything visible.

However since I upgraded from Apache 1.3 + mod_php to Apache 2.2 (mpm_worker) + PHP FastCGI (don't know how it's related, but it seems to be), the precedent rule returns a 404 error :

The requested URL /var/www/action/do.php was not found on this server.

The DocumentRoot is now inserted in the request ! The file /var/www/var/www/action/do.php obviously doesn't exist开发者_如何学Go.

As a workaround, I changed the rule : (added a / at the beginning of the second part)

RewriteEngine on
RewriteRule ^dir/([^/]+)/(.*) /action/do.php?a=$1&b=$2 [L,QSA]

And it works (because fortunately in this case, I'm in the DocumentRoot directory).

Do you know what caused this behavior change ? Did you notice the same thing ?


Ok, I found what happened.

Actually, I was not in my DocumentRoot but in a VirtualDocumentRoot thanks to mod_vhost_alias.

The issue does not happen when using "real" virtual hosts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜