Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

Rewrite Xmap URL

1
2
3
4
5
6
RewriteCond %{REQUEST_URI} ^/es/sitemap.xml
RewriteRule .* /es/index.php?option=com_xmap&view=xml&tmpl=component&id=1
RewriteCond %{REQUEST_URI} ^/en/sitemap.xml
RewriteRule .* /en/index.php?option=com_xmap&view=xml&tmpl=component&id=2
RewriteCond %{REQUEST_URI} ^/pt/sitemap.xml
RewriteRule .* /pt/index.php?option=com_xmap&view=xml&tmpl=component&id=3
https://snipt.net/embed/29b62e0c11755e05065242cf9fcd3991/
https://snipt.net/raw/29b62e0c11755e05065242cf9fcd3991/
29b62e0c11755e05065242cf9fcd3991
text
Text only
6
2016-12-09T00:39:22
True
False
False
Apr 01, 2014 at 11:48 AM
/api/public/snipt/126512/
rewrite-xmap-url
<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>RewriteCond %{REQUEST_URI} ^/es/sitemap.xml </span><span id="L-2"><a name="L-2"></a>RewriteRule .* /es/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=1 </span><span id="L-3"><a name="L-3"></a>RewriteCond %{REQUEST_URI} ^/en/sitemap.xml </span><span id="L-4"><a name="L-4"></a>RewriteRule .* /en/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=2 </span><span id="L-5"><a name="L-5"></a>RewriteCond %{REQUEST_URI} ^/pt/sitemap.xml </span><span id="L-6"><a name="L-6"></a>RewriteRule .* /pt/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=3 </span></pre></div> </td></tr></table>
htaccess, joomla, rewrite, sitemap, xmap

Nginx configuration file

Backbone.js rewrite for Nginx

1
2
3
4
5
        location / {
        		if (!-e $request_filename){
        			rewrite ^(.*)$ /index.html break;
        		}
        }
https://snipt.net/embed/ab9ed4a5f3702f4c11307dd1f510415f/
https://snipt.net/raw/ab9ed4a5f3702f4c11307dd1f510415f/
ab9ed4a5f3702f4c11307dd1f510415f
nginx
Nginx configuration file
5
2016-12-08T10:29:49
True
False
False
Apr 30, 2013 at 08:22 PM
/api/public/snipt/60379/
backbonejs-rewrite-for-nginx
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> <span class="k">location</span> <span class="s">/</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kn">if</span> <span class="s">(!-e</span> <span class="nv">$request_filename</span><span class="s">)</span><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="kn">rewrite</span> <span class="s">^(.*)</span>$ <span class="s">/index.html</span> <span class="s">break</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">}</span> </span></pre></div> </td></tr></table>
backbone.js, nginx, rewrite, rewrites

ApacheConf

Ignorando uma pasta no .htaccess

RewriteRule ^nome_pasta/.*$ - [PT]
https://snipt.net/embed/c9dbdb9a708bc98daf7a391d2435f37a/
https://snipt.net/raw/c9dbdb9a708bc98daf7a391d2435f37a/
c9dbdb9a708bc98daf7a391d2435f37a
apacheconf
ApacheConf
1
2016-12-08T06:20:12
True
False
False
/api/public/snipt/44092/
ignorando-uma-pasta-no-htaccess
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nb">RewriteRule</span> ^nome_pasta/.*$ - [PT] </span></pre></div> </td></tr></table>
apache, cakephp, mvc, rewrite

JavaScript

deny 360SE

1
2
3
4
if ($http_user_agent ~ (360SE) )   
{   
    return 404;   
}
https://snipt.net/embed/96c853a41a4756a2c1d836982b181c2c/
https://snipt.net/raw/96c853a41a4756a2c1d836982b181c2c/
96c853a41a4756a2c1d836982b181c2c
js
JavaScript
4
2016-12-06T22:08:21
True
False
False
/api/public/snipt/26896/
deny-360se
<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><span class="k">if</span> <span class="p">(</span><span class="nx">$http_user_agent</span> <span class="o">~</span> <span class="p">(</span><span class="mi">360</span><span class="nx">SE</span><span class="p">)</span> <span class="p">)</span> </span><span id="L-2"><a name="L-2"></a><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">return</span> <span class="mi">404</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
rewrite

Bash

.htaccess rewrite url

1
2
3
# check for form/thanks with or without trailing slash,
# and rewrite to /form?m=thanks
RewriteRule ^form/thanks(/$|$) /form?m=thanks
https://snipt.net/embed/4e5e6096a6f7e91d4bb7e528072de013/
https://snipt.net/raw/4e5e6096a6f7e91d4bb7e528072de013/
4e5e6096a6f7e91d4bb7e528072de013
bash
Bash
3
2016-12-02T20:46:36
True
False
False
/api/public/snipt/13344/
htaccess-rewrite-url
<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></span><span id="L-1"><a name="L-1"></a><span class="c1"># check for form/thanks with or without trailing slash,</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># and rewrite to /form?m=thanks</span> </span><span id="L-3"><a name="L-3"></a>RewriteRule ^form/thanks<span class="o">(</span>/$<span class="p">|</span>$<span class="o">)</span> /form?m<span class="o">=</span>thanks </span></pre></div> </td></tr></table>
.htaccess, apache, linux, rewrite

Bash

Rewrite .cfm files to files with .cfm

1
2
3
4
5
6
RewriteEngine On
Options -Indexes

# redirect all .cfm files to files without .cfm
RedirectMatch 301 ^(.*)\index.cfm$ $1
RedirectMatch 301 ^(.*)\.cfm$ $1
https://snipt.net/embed/ae4580230f1cfe7a14b823ef5e0fb2e0/
https://snipt.net/raw/ae4580230f1cfe7a14b823ef5e0fb2e0/
ae4580230f1cfe7a14b823ef5e0fb2e0
bash
Bash
6
2016-12-06T01:50:47
True
False
False
/api/public/snipt/12142/
rewrite-cfm-files-to-files-with-cfm
<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>RewriteEngine On </span><span id="L-2"><a name="L-2"></a>Options -Indexes </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># redirect all .cfm files to files without .cfm</span> </span><span id="L-5"><a name="L-5"></a>RedirectMatch <span class="m">301</span> ^<span class="o">(</span>.*<span class="o">)</span><span class="se">\i</span>ndex.cfm$ <span class="nv">$1</span> </span><span id="L-6"><a name="L-6"></a>RedirectMatch <span class="m">301</span> ^<span class="o">(</span>.*<span class="o">)</span><span class="se">\.</span>cfm$ <span class="nv">$1</span> </span></pre></div> </td></tr></table>
.htaccess, apache, linux, rewrite

Bash

mod_rewrite to fix blogger moving

1
2
3
4
5
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/blog/images/(.*)$ [NC]
RewriteCond %{REQUEST_URI} ^/blog/(.*)$ [NC]
RewriteRule ^blog/(.*)$ http://blog.domain.com/$1 [R=301,L]
https://snipt.net/embed/436bdcc59ca1898bea1ecf70180f99b2/
https://snipt.net/raw/436bdcc59ca1898bea1ecf70180f99b2/
436bdcc59ca1898bea1ecf70180f99b2
bash
Bash
6
2016-12-09T12:37:42
True
False
False
/api/public/snipt/11962/
mod_rewrite-to-fix-blogger-moving
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><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 %<span class="o">{</span>REQUEST_URI<span class="o">}</span> !^/blog/images/<span class="o">(</span>.*<span class="o">)</span>$ <span class="o">[</span>NC<span class="o">]</span> </span><span id="L-4"><a name="L-4"></a>RewriteCond %<span class="o">{</span>REQUEST_URI<span class="o">}</span> ^/blog/<span class="o">(</span>.*<span class="o">)</span>$ <span class="o">[</span>NC<span class="o">]</span> </span><span id="L-5"><a name="L-5"></a>RewriteRule ^blog/<span class="o">(</span>.*<span class="o">)</span>$ http://blog.domain.com/<span class="nv">$1</span> <span class="o">[</span><span class="nv">R</span><span class="o">=</span>301,L<span class="o">]</span> </span></pre></div> </td></tr></table>
htaccess, mod, rewrite
Copyrighted, illegal, or inappropriate content? Email [email protected].