如何从重写规则中排除文件

时间:2018-02-27 01:50:34

标签: .htaccess url-rewriting

我的.htaccess文件位于子目录(www.example.com/test/.htaccess)中:

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?state=$1 [QSA]

所以网址:

www.example.com/test/CA/

重定向到:www.example.com/test/index.php?state = CA

但我的问题是:www.example.com/test/form.htm还重定向

有人可以告诉我如何从规则中排除form.htm,以便它转到实际文件而不是重定向吗?谢谢大家的帮助。

1 个答案:

答案 0 :(得分:0)

我通过执行以下操作将html和php文件排除在条件之外:

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(php|htm)$
RewriteRule ^([^/d]+)/?$ index.php?state=$1 [QSA]