snipt

Ctrl+h for KB shortcuts

Text only

htaccess - Redirect all traffic from old domain to new domain passing urls

RewriteEngine on 
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]
https://snipt.net/embed/13ba2bde87c6921292407f3b1faf3062/
https://snipt.net/raw/13ba2bde87c6921292407f3b1faf3062/
13ba2bde87c6921292407f3b1faf3062
text
Text only
2
2016-09-27T04:50:38
True
False
False
Jul 05, 2013 at 01:41 PM
/api/public/snipt/66541/
htaccess-redirect-all-traffic-from-old-domain-to-new-domain-passing-urls
<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>RewriteEngine on </span><span id="L-2"><a name="L-2"></a>RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L] </span></pre></div> </td></tr></table>
301, htaccess, redirect, seo

Text only

non-www to www domain htacess

1
2
3
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
https://snipt.net/embed/91b0d9cd3b22e470030d3a313253042a/
https://snipt.net/raw/91b0d9cd3b22e470030d3a313253042a/
91b0d9cd3b22e470030d3a313253042a
text
Text only
3
2016-09-28T06:42:09
True
False
False
/api/public/snipt/13713/
non-www-to-www-domain-htacess
<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>RewriteEngine on </span><span id="L-2"><a name="L-2"></a>RewriteCond %{HTTP_HOST} !^www.your_domain.com$ </span><span id="L-3"><a name="L-3"></a>RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301] </span></pre></div> </td></tr></table>
seo

Text only

A better solution for removing default.aspx from an IIS CMS

RewriteCond %{THE_REQUEST} ^.*\/\ HTTP/
RewriteRule ^(.*)/?$ $1/default.aspx [nc,l]
https://snipt.net/embed/fa5de6f07d567b20aaaa7baffd8f4f00/
https://snipt.net/raw/fa5de6f07d567b20aaaa7baffd8f4f00/
fa5de6f07d567b20aaaa7baffd8f4f00
text
Text only
2
2016-09-28T06:42:15
True
False
False
/api/public/snipt/13054/
a-better-solution-for-removing-defaultaspx-from-an-iis-cms
<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 %{THE_REQUEST} ^.*\/\ HTTP/ </span><span id="L-2"><a name="L-2"></a>RewriteRule ^(.*)/?$ $1/default.aspx [nc,l] </span></pre></div> </td></tr></table>
"iss rewrites", isapi_rewrite, seo

Text only

redirect all urls that do not have a trailing slash to urls with a trailing slash

1
2
3
4
5
6
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] 
https://snipt.net/embed/9e8e1b1c34d914bbbbc3825b1e6c4490/
https://snipt.net/raw/9e8e1b1c34d914bbbbc3825b1e6c4490/
9e8e1b1c34d914bbbbc3825b1e6c4490
text
Text only
6
2016-09-28T06:42:20
True
False
False
/api/public/snipt/12994/
redirect-all-urls-that-do-not-have-a-trailing-slash-to-urls-with-a-trailing-slash
<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 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 %{REQUEST_FILENAME} !-f </span><span id="L-4"><a name="L-4"></a>RewriteCond %{REQUEST_URI} !example.php </span><span id="L-5"><a name="L-5"></a>RewriteCond %{REQUEST_URI} !(.*)/$ </span><span id="L-6"><a name="L-6"></a>RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] </span></pre></div> </td></tr></table>
seo

Text only

Force all Upper Case URL's to lower case and redirect to lowercase

1
2
3
4
5
6
## Rewrite all MiXed Case uRLs to lower case URL's and 301 redirect in one elegant statement ##

RewriteEngine On
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
https://snipt.net/embed/8beaa95d007c906e725f2c302ecd7922/
https://snipt.net/raw/8beaa95d007c906e725f2c302ecd7922/
8beaa95d007c906e725f2c302ecd7922
text
Text only
7
2016-09-28T06:42:26
True
False
False
/api/public/snipt/12951/
force-all-upper-case-urls-to-lower-case-and-redirect-to-lowercase
<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 id="L-1"><a name="L-1"></a>## Rewrite all MiXed Case uRLs to lower case URL&#39;s and 301 redirect in one elegant statement ## </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>RewriteEngine On </span><span id="L-4"><a name="L-4"></a>RewriteMap lc int:tolower </span><span id="L-5"><a name="L-5"></a>RewriteCond %{REQUEST_URI} [A-Z] </span><span id="L-6"><a name="L-6"></a>RewriteRule (.*) ${lc:$1} [R=301,L] </span></pre></div> </td></tr></table>
mod_rewrite, seo, url
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.