snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#33305

Text only

Redirect non www to www:

1
2
3
4
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
https://snipt.net/embed/d7e79e8580194d1b5902410eaf2bb6e9/
https://snipt.net/raw/d7e79e8580194d1b5902410eaf2bb6e9/
d7e79e8580194d1b5902410eaf2bb6e9
text
Text only
5
2014-04-19T16:40:36
True
False
/api/public/snipt/33305/
redirect-www-to-www-non
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>RewriteEngine On </span><span id="L-2"><a name="L-2"></a>RewriteBase / </span><span id="L-3"><a name="L-3"></a>RewriteCond %{HTTP_HOST} ^yourdomain.com [NC] </span><span id="L-4"><a name="L-4"></a>RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301] </span></pre></div> </td></tr></table>
htacess
#33303

Text only

Rewrite url

1
2
3
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]
https://snipt.net/embed/fcf5bf24f7bc6eff99e83b28f7f96e17/
https://snipt.net/raw/fcf5bf24f7bc6eff99e83b28f7f96e17/
fcf5bf24f7bc6eff99e83b28f7f96e17
text
Text only
3
2014-04-23T12:40:17
True
False
/api/public/snipt/33303/
rewrite-url-1
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>Options +FollowSymlinks </span><span id="L-2"><a name="L-2"></a>RewriteEngine on </span><span id="L-3"><a name="L-3"></a>RewriteRule ^(.*)\.htm$ $1.php [nc] </span></pre></div> </td></tr></table>
.htaccess
#33302

Text only

Redirect no www to www

 RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
 RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
https://snipt.net/embed/a1469817959a2b51921e6f6fd5383877/
https://snipt.net/raw/a1469817959a2b51921e6f6fd5383877/
a1469817959a2b51921e6f6fd5383877
text
Text only
2
2014-04-05T03:04:43
True
False
/api/public/snipt/33302/
redirect-no-www-to-www
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a> RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] </span><span id="L-2"><a name="L-2"></a> RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] </span></pre></div> </td></tr></table>
htaccess