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-16T09:00:33
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/
/raw/ae4580230f1cfe7a14b823ef5e0fb2e0/
ae4580230f1cfe7a14b823ef5e0fb2e0
bash
Bash
6
2019-07-12T14:33:36
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