snipt

Ctrl+h for KB shortcuts

Perl

htaccess redirection

#redirect index.php to root
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.domain.com/$1 [R=301,L]

#redirect domain.com to www.domain.com
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
https://snipt.net/embed/c538e414a46bf96c4cc0ee77977caa6e/
/raw/c538e414a46bf96c4cc0ee77977caa6e/
c538e414a46bf96c4cc0ee77977caa6e
perl
Perl
10
2019-08-25T19:04:45
True
False
False
/api/public/snipt/24541/
htaccess-redirection
<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> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">#redirect index.php to root</span> </span><span id="L-2"><a name="L-2"></a><span class="n">Options</span> <span class="o">+</span><span class="n">FollowSymLinks</span> </span><span id="L-3"><a name="L-3"></a><span class="n">RewriteCond</span> <span class="nv">%</span><span class="p">{</span><span class="n">THE_REQUEST</span><span class="p">}</span> <span class="o">^.*/</span><span class="nb">index</span><span class="o">.</span><span class="n">php</span> </span><span id="L-4"><a name="L-4"></a><span class="n">RewriteRule</span> <span class="o">^</span><span class="p">(</span><span class="o">.*</span><span class="p">)</span><span class="nb">index</span><span class="o">.</span><span class="n">php</span><span class="nv">$</span> <span class="nv">http:</span><span class="sr">//</span><span class="n">www</span><span class="o">.</span><span class="n">domain</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="nv">$1</span> <span class="p">[</span><span class="n">R</span><span class="o">=</span><span class="mi">301</span><span class="p">,</span><span class="n">L</span><span class="p">]</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">#redirect domain.com to www.domain.com</span> </span><span id="L-7"><a name="L-7"></a><span class="n">Options</span> <span class="o">+</span><span class="n">FollowSymlinks</span> </span><span id="L-8"><a name="L-8"></a><span class="n">RewriteEngine</span> <span class="n">on</span> </span><span id="L-9"><a name="L-9"></a><span class="n">rewritecond</span> <span class="nv">%</span><span class="p">{</span><span class="n">http_host</span><span class="p">}</span> <span class="o">^</span><span class="n">domain</span><span class="o">.</span><span class="n">com</span> <span class="p">[</span><span class="n">nc</span><span class="p">]</span> </span><span id="L-10"><a name="L-10"></a><span class="n">rewriterule</span> <span class="o">^</span><span class="p">(</span><span class="o">.*</span><span class="p">)</span><span class="nv">$</span> <span class="nv">http:</span><span class="sr">//</span><span class="n">www</span><span class="o">.</span><span class="n">domain</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="nv">$1</span> <span class="p">[</span><span class="n">r</span><span class="o">=</span><span class="mi">301</span><span class="p">,</span><span class="n">nc</span><span class="p">]</span> </span></pre></div> </td></tr></table>
apache, htaccess, index.php, joomla, redirection