开发者

mod_rewrite - how to avoid infinite loop

I want to have a nice URLs on my website, so I have added this line into .htaccess, but it's causing infinite loop开发者_如何转开发.

RewriteRule ^(.*)$ http://www.mydomain.com/pages/$1%{QUERY_STRING}.php

It should rewrite every URL and add "pages/" and ".php" extension but only FIRST TIME not like some kind of recursive function.


you don't need to pass the query string, that happens automatically.
see the documentation

other than that, try this

RewriteCond %{REQUEST_URI}  !^/pages/$
RewriteRule ^(/.*)? http://www.mydomain.com/pages/$1 [L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜