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_STRING
yourself; 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
RewriteRule
with aRewriteCond
that precedes it. For example:RewriteCond %{REQUEST_URI} !^/staticpage.html$
RewriteRule ^(.*)\.html$ index.php?pagename=$1 [QSA]
Another useful pattern is
RewriteCond %{REQUEST_FILENAME} !-f
which will bypass the followingRewriteRule
any time that the URL would have matched an existing regular file in the docroot.
精彩评论