snipt

Ctrl+h for KB shortcuts

ApacheConf

HTACCESS - File Name and File Type Conditions

1
2
3
4
5
6
# Don't redirect these files
RewriteCond %{REQUEST_URI} !(page1|page_one|page_one_1)\.html$
# Don't redirect these file types
RewriteCond %{REQUEST_FILENAME} !\.(css|js|xml|jpg|png|gif|eot|woff|ttf)$
# Redirect everything else
RewriteRule ^(.*)$ http://%{HTTP_HOST}/newpage.html [R=301,L]
https://snipt.net/embed/16c83996f079b1553da1c6d3f7324472/
/raw/16c83996f079b1553da1c6d3f7324472/
16c83996f079b1553da1c6d3f7324472
apacheconf
ApacheConf
6
2019-08-25T09:11:02
True
False
False
/api/public/snipt/115787/
htaccess-filename-and-file-type-conditions
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c"># Don&#39;t redirect these files</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">RewriteCond</span> %{REQUEST_URI} !(page1|page_one|page_one_1)\.html$ </span><span id="L-3"><a name="L-3"></a><span class="c"># Don&#39;t redirect these file types</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">RewriteCond</span> %{REQUEST_FILENAME} !\.(css|js|xml|jpg|png|gif|eot|woff|ttf)$ </span><span id="L-5"><a name="L-5"></a><span class="c"># Redirect everything else</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">RewriteRule</span> ^(.*)$ http://%{HTTP_HOST}/newpage.html [R=301,L] </span></pre></div> </td></tr></table>
htaccess