snipt

Ctrl+h for KB shortcuts

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/
/raw/4e5e6096a6f7e91d4bb7e528072de013/
4e5e6096a6f7e91d4bb7e528072de013
bash
Bash
3
2019-07-17T19:23:10
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

.htaccess file to lock down files with db or secure in the prefix

1
2
3
<FilesMatch "^(db|secure).*$">
deny from all
</FilesMatch>
https://snipt.net/embed/157dba3965602938b8e43226c77b9514/
/raw/157dba3965602938b8e43226c77b9514/
157dba3965602938b8e43226c77b9514
bash
Bash
4
2019-06-10T12:15:35
True
False
False
/api/public/snipt/12528/
htaccess-file-to-lock-down-files-with-db-or-secure-in-the-prefix
<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>&lt;FilesMatch <span class="s2">&quot;^(db|secure).*</span>$<span class="s2">&quot;</span>&gt; </span><span id="L-2"><a name="L-2"></a>deny from all </span><span id="L-3"><a name="L-3"></a>&lt;/FilesMatch&gt; </span></pre></div> </td></tr></table>
.htaccess, apache, linux

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/
/raw/ae4580230f1cfe7a14b823ef5e0fb2e0/
ae4580230f1cfe7a14b823ef5e0fb2e0
bash
Bash
6
2019-07-17T16:13:15
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

remove newline chars in vi

1
2
3
:%s/^v<Carriage Return>//g

*hit the ctrl key + v then hit the carriage return.
https://snipt.net/embed/93b41e5ce27ed4ee81eb0f59144c7974/
/raw/93b41e5ce27ed4ee81eb0f59144c7974/
93b41e5ce27ed4ee81eb0f59144c7974
bash
Bash
3
2019-07-19T11:19:29
True
False
False
/api/public/snipt/10600/
remove-newline-chars-in-vi
<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>:%s/^v&lt;Carriage Return&gt;//g </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>*hit the ctrl key + v <span class="k">then</span> hit the carriage <span class="k">return</span>. </span></pre></div> </td></tr></table>
linux, newline, vi