Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see 4 main approaches (you choose which one suits you more - it depends on your website rewrite rules logic):</p> <p><strong>1. Add global exclusion rule that will prevent ANY further rewrite operations on that file</strong>:</p> <pre><code>RewriteCond %{HTTP_HOST} ^website.com RewriteRule (.*) http://www.website.com/$1 [R=301,L] # do not do any rewriting to this file RewriteRule somefile\.html$ - [L] RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L] </code></pre> <p>If you wish you can specify full path to the file to be more specific (useful to exclude only 1 specific file if there are more than 1 file with such name but in different folders -- such URL should start with NO leading slash):</p> <pre><code># do not do any rewriting to this file RewriteRule ^full/path/to/somefile\.html$ - [L] </code></pre> <p><strong>2. Add global exclusion rule that will prevent ANY further rewrite operations on ANY existing file or folder</strong>:</p> <pre><code>RewriteCond %{HTTP_HOST} ^website.com RewriteRule (.*) http://www.website.com/$1 [R=301,L] # do not do anything for already existing files RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .+ - [L] RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L] </code></pre> <p><strong>3. Add exclusion condition that will deny rewriting this particular .html file to .php</strong>:</p> <pre><code>RewriteCond %{REQUEST_URI} !somefile\.html$ RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L] </code></pre> <p>If you wish you can specify full path to the file to be more specific (useful to exclude only 1 specific file if there are more than 1 file with such name but in different folders -- such URL should start with leading slash):</p> <pre><code>RewriteCond %{REQUEST_URI} !^/full/url/path/to/somefile\.html$ </code></pre> <p><strong>4. Add exclusion condition that will only allow rewriting .html to .php if such .html file does not exist</strong>:</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L] </code></pre> <p><strong>ALL RULES ABOVE</strong> intended to be placed in .htaccess in website root folder. If placed elsewhere some small tweaking may be required.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload