正确构造具有多个规则/ conds的htaccess

时间:2010-08-26 09:23:36

标签: php .htaccess

我如何正确构造这个htaccess文件,以便按顺序正确运行并避免无限循环?

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
RewriteBase /
RewriteRule ^deviceToken/$ devicetoken.php [QSA,L]
RewriteRule ^register/$ register.php [QSA,L]
RewriteRule ^resetPassword/$ resetpassword.php [QSA,L]
RewriteRule ^deleteLink/$ deletelink.php [QSA,L]
RewriteRule ^getLinks/$ getlinks.php [QSA,L]
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)|(\.swf)|(\.xpi)|(\.ico)|(\.src)$ 
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule (.*)$ get.php?code=$1 [L]

1 个答案:

答案 0 :(得分:1)

看起来不错,你试过吗?

这条线没用:

RewriteCond %{REQUEST_URI} ^(.*)$

首先重定向域名:

RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

(已添加,L