snipt

Ctrl+h for KB shortcuts

Text only

Dynamic SVG file

1
2
3
4
5
.htaccess:
AddType application/x-httpd-php .svg

*.svg file:
header('content-type: text/xml');
https://snipt.net/embed/f0e0adc0bd9b52d4f0e49343e6383d8f/
/raw/f0e0adc0bd9b52d4f0e49343e6383d8f/
f0e0adc0bd9b52d4f0e49343e6383d8f
text
Text only
6
2019-08-12T05:40:47
True
False
False
/api/public/snipt/3344/
dynamic-svg-file
<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>.htaccess: </span><span id="L-2"><a name="L-2"></a>AddType application/x-httpd-php .svg </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>*.svg file: </span><span id="L-5"><a name="L-5"></a>header(&#39;content-type: text/xml&#39;); </span></pre></div> </td></tr></table>
htaccess, php, svg

ApacheConf

apache .htaccess code to load site with www prefix at all times

1
2
3
4
5
6
7
# this code in your .htaccess file makes sure that the url loads 
# with the 'www.' subdomain in place...
# 
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^yourdomain.com [nc]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,nc,L]
https://snipt.net/embed/8bbfa2939b5478163efabbc0da9ae4fc/
/raw/8bbfa2939b5478163efabbc0da9ae4fc/
8bbfa2939b5478163efabbc0da9ae4fc
apacheconf
ApacheConf
7
2019-08-19T16:12:10
True
False
False
/api/public/snipt/3171/
apache-htaccess-code-to-load-site-with-www-prefix-at-all-times
<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="c"># this code in your .htaccess file makes sure that the url loads </span> </span><span id="L-2"><a name="L-2"></a><span class="c"># with the &#39;www.&#39; subdomain in place...</span> </span><span id="L-3"><a name="L-3"></a><span class="c"># </span> </span><span id="L-4"><a name="L-4"></a><span class="nb">Options</span> +FollowSymLinks </span><span id="L-5"><a name="L-5"></a><span class="nb">RewriteEngine</span> <span class="k">On</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">RewriteCond</span> %{http_host} ^yourdomain.com [nc] </span><span id="L-7"><a name="L-7"></a><span class="nb">RewriteRule</span> ^(.*)$ http://www.yourdomain.com/$1 [R=301,nc,L] </span></pre></div> </td></tr></table>
.htaccess, always, apache, conf, config, htaccess, load, site, subdomain, www

Text only

Enable 404

ErrorDocument 404 /404
https://snipt.net/embed/312915e79a00c46c489bc44fafcf8d5d/
/raw/312915e79a00c46c489bc44fafcf8d5d/
312915e79a00c46c489bc44fafcf8d5d
text
Text only
1
2019-07-30T17:00:41
True
False
False
/api/public/snipt/2766/
enable-404
<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>ErrorDocument 404 /404 </span></pre></div> </td></tr></table>
404, htaccess

Text only

Enable Deflate

1
2
3
<FilesMatch "\\.(js|css|html|htm|php|xml)$">
   SetOutputFilter DEFLATE
</FilesMatch>
https://snipt.net/embed/5b31ec55be7f7d44321f047b9fdc6b89/
/raw/5b31ec55be7f7d44321f047b9fdc6b89/
5b31ec55be7f7d44321f047b9fdc6b89
text
Text only
3
2019-08-09T23:20:51
True
False
False
/api/public/snipt/2765/
enable-deflate
<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 &quot;\\.(js|css|html|htm|php|xml)$&quot;&gt; </span><span id="L-2"><a name="L-2"></a> SetOutputFilter DEFLATE </span><span id="L-3"><a name="L-3"></a>&lt;/FilesMatch&gt; </span></pre></div> </td></tr></table>
deflate, htaccess, optimization

Text only

Enable Expires

1
2
3
4
5
6
<ifmodule mod_expires.c>
  <filesmatch "\.(jpg|gif|png|css|js)$">
       ExpiresActive on
       ExpiresDefault "access plus 7 days"
   </filesmatch>
</ifmodule>
https://snipt.net/embed/07fcec8d28269392f605f3b22ce4fbd6/
/raw/07fcec8d28269392f605f3b22ce4fbd6/
07fcec8d28269392f605f3b22ce4fbd6
text
Text only
6
2019-08-13T22:11:34
True
False
False
/api/public/snipt/2764/
enable-expires
<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>&lt;ifmodule mod_expires.c&gt; </span><span id="L-2"><a name="L-2"></a> &lt;filesmatch &quot;\.(jpg|gif|png|css|js)$&quot;&gt; </span><span id="L-3"><a name="L-3"></a> ExpiresActive on </span><span id="L-4"><a name="L-4"></a> ExpiresDefault &quot;access plus 7 days&quot; </span><span id="L-5"><a name="L-5"></a> &lt;/filesmatch&gt; </span><span id="L-6"><a name="L-6"></a>&lt;/ifmodule&gt; </span></pre></div> </td></tr></table>
expires, htaccess, optimization

Text only

Enable ETags

FileETag MTime Size
https://snipt.net/embed/a78c41c1315a97bcf1d5a3fe09868f11/
/raw/a78c41c1315a97bcf1d5a3fe09868f11/
a78c41c1315a97bcf1d5a3fe09868f11
text
Text only
1
2019-08-14T17:10:23
True
False
False
/api/public/snipt/2763/
enable-etags
<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>FileETag MTime Size </span></pre></div> </td></tr></table>
etags, htaccess, optimization

ApacheConf

how to turn on mod rewrite for base drupal installation

1
2
3
4
5
6
7
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
https://snipt.net/embed/eabee647cf327ee404acbc89d1cec00e/
/raw/eabee647cf327ee404acbc89d1cec00e/
eabee647cf327ee404acbc89d1cec00e
apacheconf
ApacheConf
7
2019-08-14T00:07:16
True
False
False
/api/public/snipt/2414/
how-to-turn-on-mod-rewrite-for-base-drupal-installation
<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="nt">&lt;IfModule</span> <span class="s">mod_rewrite.c</span><span class="nt">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="nb">RewriteEngine</span> <span class="k">on</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">RewriteBase</span> / </span><span id="L-4"><a name="L-4"></a> <span class="nb">RewriteCond</span> %{REQUEST_FILENAME} !-f </span><span id="L-5"><a name="L-5"></a> <span class="nb">RewriteCond</span> %{REQUEST_FILENAME} !-d </span><span id="L-6"><a name="L-6"></a> <span class="nb">RewriteRule</span> ^(.*)$ index.php?q=$1 [L,QSA] </span><span id="L-7"><a name="L-7"></a><span class="nt">&lt;/IfModule&gt;</span> </span></pre></div> </td></tr></table>
drupal, htaccess

Text only

set php to run with php5 in htaccess

AddType x-mapp-php5 .php
https://snipt.net/embed/807f2d70419959efdb87cf004610db6e/
/raw/807f2d70419959efdb87cf004610db6e/
807f2d70419959efdb87cf004610db6e
text
Text only
1
2019-08-20T17:31:14
True
False
False
/api/public/snipt/2409/
set-php-to-run-with-php5-in-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>AddType x-mapp-php5 .php </span></pre></div> </td></tr></table>
htaccess, php