Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 如何编写重写规则以对一个文件进行例外_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 如何编写重写规则以对一个文件进行例外

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字符串自己没有意义;如果没有,您将留下一个零散的

我当前在.htaccess文件中有以下内容:

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中的现有常规文件匹配的任何时候绕过以下
    重写规则