snipt

Ctrl+h for KB shortcuts

Text only

Redirect non-www to www

1
2
3
4
# Redirect all website.com traffic to www.website.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L]
https://snipt.net/embed/c17b712e6b2f6fee1d8ccba789a4a517/
/raw/c17b712e6b2f6fee1d8ccba789a4a517/
c17b712e6b2f6fee1d8ccba789a4a517
text
Text only
4
2019-07-18T15:25:54
True
False
False
/api/public/snipt/28079/
redirect-non-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> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># Redirect all website.com traffic to www.website.com </span><span id="L-2"><a name="L-2"></a>RewriteEngine On </span><span id="L-3"><a name="L-3"></a>RewriteCond %{HTTP_HOST} ^website\.com$ [NC] </span><span id="L-4"><a name="L-4"></a>RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L] </span></pre></div> </td></tr></table>
htaccess, non-www, www