开发者

mod_rewrite - how to avoid infinite loop

开发者 https://www.devze.com 2023-03-27 11:03 出处:网络
I want to have a nice URLs on my website, so I have added this line into .htaccess, but it\'s causing 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

精彩评论

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

关注公众号