views:

83

answers:

1

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 allow access to one particular static html file, so somehow I need to overwrite the rule or make an exception.

Thanks for you help.

+3  A: 
  1. 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]

  2. You can control a RewriteRule with a RewriteCond that precedes it. For example:

    RewriteCond %{REQUEST_URI} !^/staticpage.html$
    RewriteRule ^(.*)\.html$ index.php?pagename=$1 [QSA]

  3. Another useful pattern is RewriteCond %{REQUEST_FILENAME} !-f which will bypass the following RewriteRule any time that the URL would have matched an existing regular file in the docroot.

hobbs