Flo*_*ram 1 apache .htaccess mod-rewrite
我目前在我的.htaccess文件中有这个:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)\.html$ index.php?pagename=$1&%{QUERY_STRING}
Run Code Online (Sandbox Code Playgroud)
将html文件名重写为pagename查询字符串.
但是我试图允许访问一个特定的静态html文件,所以不知何故我需要覆盖规则或异常.
谢谢你的帮助.
没有必要追加QUERY_STRING自己; &如果没有,你会留下一个迷路,而且mod_rewrite已经有了一个更好的工具:
RewriteRule ^(.*)\.html$ index.php?pagename=$1 [QSA]
您可以RewriteRule使用RewriteCond前面的控件来控制.例如:
RewriteCond %{REQUEST_URI} !^/staticpage.html$
RewriteRule ^(.*)\.html$ index.php?pagename=$1 [QSA]
另一个有用的模式是RewriteCond %{REQUEST_FILENAME} !-f将绕过下列RewriteRule 任何的URL会匹配在文档根现有的常规文件的时间.