How would I write a RewriteRule to make an exception for one file
I currently have this in my .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)\.html$ index.php?pagename=$1&%{QUERY_STRING}
The the html file name is rewritten to the pagename query string.
However I'm trying to al开发者_运维百科low access to one particular static html file, so somehow I need to overwrite the rule or make an exception.
Thanks for you help.
No point appending
QUERY_STRINGyourself; you'll leave a stray&if there isn't any, and mod_rewrite already has a tool to do it better:RewriteRule ^(.*)\.html$ index.php?pagename=$1 [QSA]You can control a
RewriteRulewith aRewriteCondthat precedes it. For example:RewriteCond %{REQUEST_URI} !^/staticpage.html$
RewriteRule ^(.*)\.html$ index.php?pagename=$1 [QSA]Another useful pattern is
RewriteCond %{REQUEST_FILENAME} !-fwhich will bypass the followingRewriteRuleany time that the URL would have matched an existing regular file in the docroot.
加载中,请稍侯......
精彩评论