【问题标题】:How to exclude a file from a re-write rule如何从重写规则中排除文件
【发布时间】:2018-02-27 01:50:34
【问题描述】:

我在子目录 (www.example.com/test/.htaccess) 的 .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 以使其进入实际文件而不是重定向吗?谢谢大家的帮助。

【问题讨论】:

    标签: .htaccess url-rewriting


    【解决方案1】:

    我通过执行以下操作排除了 html 和 php 文件作为条件:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-22
      • 2015-03-21
      • 1970-01-01
      • 1970-01-01
      • 2016-12-27
      • 2012-09-15
      • 2015-08-03
      • 2010-12-23
      相关资源
      最近更新 更多