Apache 如何编写重写规则以对一个文件进行例外
我当前在.htaccess文件中有以下内容:Apache 如何编写重写规则以对一个文件进行例外,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我当前在.htaccess文件中有以下内容: Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*)\.html$ index.php?pagename=$1&%{QUERY_STRING} html文件名将重写为pagename查询字符串 然而,我正试图允许访问一个特定的静态html文件,所以我需要以某种方式覆盖规则或创建一个例外 谢谢你的帮助 添加QUERY\u字符串自己没有意义;如果没有,您将留下一个零散的
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)\.html$ index.php?pagename=$1&%{QUERY_STRING}
html文件名将重写为pagename查询字符串
然而,我正试图允许访问一个特定的静态html文件,所以我需要以某种方式覆盖规则或创建一个例外
谢谢你的帮助
QUERY\u字符串
自己没有意义;如果没有,您将留下一个零散的&
,并且mod_rewrite已经有了一个更好的工具:
RewriteRule^(.*)\.html$index.php?pagename=$1[QSA]
RewriteCond
控制RewriteRule
。例如:
RewriteCond%{REQUEST\u URI}^/staticpage.html$
RewriteRule^(.*)\.html$index.php?pagename=$1[QSA]
RewriteCond%{REQUEST\u FILENAME}-f
这将在URL与docroot中的现有常规文件匹配的任何时候绕过以下重写规则
QUERY\u字符串
自己没有意义;如果没有,您将留下一个零散的&
,并且mod_rewrite已经有了一个更好的工具:
RewriteRule^(.*)\.html$index.php?pagename=$1[QSA]
RewriteCond
控制RewriteRule
。例如:
RewriteCond%{REQUEST\u URI}^/staticpage.html$
RewriteRule^(.*)\.html$index.php?pagename=$1[QSA]
RewriteCond%{REQUEST\u FILENAME}-f
这将在URL与docroot中的现有常规文件匹配的任何时候绕过以下重写规则