开发者

Weird ModRewrite recursion

I have written this simple .htaccess file on my localhost for testing:

RewriteEngine on
RewriteRule ^(.+)$ $1a    
RewriteRule ^(.+)$ $1b 

Now requesting http://localhost/test/x, I get the error Forbidden on /test/xa/xba/xa/xbba/xa/xba/xa/xbbba/xa/xba/xa/x开发者_高级运维bba/xa/xba/xa/xbbbba/...

I don't understand why this happens, since I don't use the [N] flag, or anything else, that should cause mod_rewrite to recurse. Also, even if it did recurse, I would expect /test/xabababababababababa... not that nearly tree looking pattern above.

Can anyone tell me what's going on?


Because that is how mod_rewrite works -- after rewriting happens it goes to next iteration (when exactly -- it depends on rewrite flags and other "moments").

If you do not build your rule in a correct manner you will have rewrite loop, which Apache has to forcibly stop at some point.

Useful link to read: RewriteRule Last [L] flag not working?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜