Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

Remove File Extension from URLs in .htaccess

1
2
3
4
5
6
7
8
# Sample 1: 
RewriteRule ^about$ about.php [L]
 
# Sample 2: 
RewriteCond /%{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php

source: http://apphp.com/index.php?snippet=htaccess-remove-file-extension-from-url
https://snipt.net/embed/861d04fa4d31b0d94447aebef2dcc178/
https://snipt.net/raw/861d04fa4d31b0d94447aebef2dcc178/
861d04fa4d31b0d94447aebef2dcc178
text
Text only
8
2016-12-02T17:19:51
True
False
False
Feb 16, 2014 at 03:24 AM
/api/public/snipt/114086/
remove-file-extension-from-urls-in-htaccess
<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> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># Sample 1: </span><span id="L-2"><a name="L-2"></a>RewriteRule ^about$ about.php [L] </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a># Sample 2: </span><span id="L-5"><a name="L-5"></a>RewriteCond /%{REQUEST_FILENAME}.php -f </span><span id="L-6"><a name="L-6"></a>RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a>source: http://apphp.com/index.php?snippet=htaccess-remove-file-extension-from-url </span></pre></div> </td></tr></table>
"remove file extension", apphp, htaccess

Text only

Different Directory Index Page in .htaccess

1
2
3
4
5
6
7
# Sample 1: 
DirectoryIndex index2.html
 
# Sample 2: 
DirectoryIndex index2.php

source: http://apphp.com/index.php?snippet=htaccess-different-directory-index-page
https://snipt.net/embed/5d34ee29a364c2aa8b7905c06c6b662f/
https://snipt.net/raw/5d34ee29a364c2aa8b7905c06c6b662f/
5d34ee29a364c2aa8b7905c06c6b662f
text
Text only
7
2016-12-04T19:32:13
True
False
False
Feb 16, 2014 at 03:23 AM
/api/public/snipt/114085/
different-directory-index-page-in-htaccess
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># Sample 1: </span><span id="L-2"><a name="L-2"></a>DirectoryIndex index2.html </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a># Sample 2: </span><span id="L-5"><a name="L-5"></a>DirectoryIndex index2.php </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>source: http://apphp.com/index.php?snippet=htaccess-different-directory-index-page </span></pre></div> </td></tr></table>
apphp, htaccess

SQL

Find and Replace with MySQL

1
2
3
4
5
6
7
-- 1st example
UPDATE files SET filepath = REPLACE(filepath,'path/to/search','path/to/replace');
 
-- 2nd example
UPDATE customers SET address = REPLACE(address,'_CODE_',postcode);

-- source: http://www.apphp.com/index.php?snippet=mysql-find-and-replace
https://snipt.net/embed/b67af5219e24b0e1826af1d8c3d5fa8e/
https://snipt.net/raw/b67af5219e24b0e1826af1d8c3d5fa8e/
b67af5219e24b0e1826af1d8c3d5fa8e
sql
SQL
7
2016-12-06T03:04:29
True
False
False
Feb 12, 2014 at 02:35 AM
/api/public/snipt/112918/
find-and-replace-with-mysql
<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> <a href="#L-7">7</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">-- 1st example</span> </span><span id="L-2"><a name="L-2"></a><span class="k">UPDATE</span> <span class="n">files</span> <span class="k">SET</span> <span class="n">filepath</span> <span class="o">=</span> <span class="k">REPLACE</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span><span class="s1">&#39;path/to/search&#39;</span><span class="p">,</span><span class="s1">&#39;path/to/replace&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">-- 2nd example</span> </span><span id="L-5"><a name="L-5"></a><span class="k">UPDATE</span> <span class="n">customers</span> <span class="k">SET</span> <span class="n">address</span> <span class="o">=</span> <span class="k">REPLACE</span><span class="p">(</span><span class="n">address</span><span class="p">,</span><span class="s1">&#39;_CODE_&#39;</span><span class="p">,</span><span class="n">postcode</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c1">-- source: http://www.apphp.com/index.php?snippet=mysql-find-and-replace</span> </span></pre></div> </td></tr></table>
"replace string", apphp, sql
Copyrighted, illegal, or inappropriate content? Email [email protected].