snipt

Ctrl+h for KB shortcuts

Text only

Custom HTACCESS rules used on Joomla! sites we build

# Tip: Paste the following right below 'RewriteEngine on' and do NOT change the order of rules
# Notice: These rules may not work on websites using a CDN. In that case, you may want to use rules with hardcoded domains

########## CUSTOM RULES - START ##########

# File execution order
DirectoryIndex index.php index.html

# Added to prevent directory browsing
Options -Indexes

# Google Apps (replace domain.com with your domain, without the www portion)
Redirect 301 /mail http://mail.google.com/a/domain.com
Redirect 301 /docs http://docs.google.com/a/domain.com

# Or do the above automatically by uncommenting the 4 lines below and commenting the above 2
#RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$
#RewriteRule ^mail[/]{0,1}$ http://mail.google.com/a/%2 [R=301,L]
#RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$
#RewriteRule ^docs[/]{0,1}$ http://docs.google.com/a/%2 [R=301,L]

# Redirect webmail.domain.tld to domain:2095 for cPanel Webmail only - COMMENTED by default
#RewriteCond %{HTTP_HOST} ^webmail\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/webmail/$1 [R=301,L]

# Redirect /index.php to / - will also clear /index.php/something to /something
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ /$2 [R=301,L]

# Redirect non-www to www - NOT COMMENTED by default
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Redirect non-www to www - COMMENTED by default - use for FIXED domain
#RewriteCond %{HTTP_HOST} ^domain.com [nc]
#RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,L]

# Redirect www to non-www - COMMENTED by default
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Compress text, html, javascript, css, xml, fonts
Addtype font/opentype .otf
Addtype font/truetype .ttf
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript font/opentype font/truetype

# Allow Firefox to load fonts from different domains (e.g. a CDN location)
<FilesMatch "\.(woff|eot|svg|ttf)">
	Header set Access-Control-Allow-Origin *
</FilesMatch>

########## CUSTOM RULES - END ##########
https://snippets.siftie.com/embed/f999a5df70034f8fca5fa17be2abeef9/
/raw/f999a5df70034f8fca5fa17be2abeef9/
f999a5df70034f8fca5fa17be2abeef9
text
Text only
53
2019-02-16T06:13:33
True
False
False
Sep 06, 2012 at 12:10 PM
/api/public/snipt/18180/
custom-htaccess-rules-used-on-joomla-sites-we-build
<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> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a> <a href="#L-13">13</a> <a href="#L-14">14</a> <a href="#L-15">15</a> <a href="#L-16">16</a> <a href="#L-17">17</a> <a href="#L-18">18</a> <a href="#L-19">19</a> <a href="#L-20">20</a> <a href="#L-21">21</a> <a href="#L-22">22</a> <a href="#L-23">23</a> <a href="#L-24">24</a> <a href="#L-25">25</a> <a href="#L-26">26</a> <a href="#L-27">27</a> <a href="#L-28">28</a> <a href="#L-29">29</a> <a href="#L-30">30</a> <a href="#L-31">31</a> <a href="#L-32">32</a> <a href="#L-33">33</a> <a href="#L-34">34</a> <a href="#L-35">35</a> <a href="#L-36">36</a> <a href="#L-37">37</a> <a href="#L-38">38</a> <a href="#L-39">39</a> <a href="#L-40">40</a> <a href="#L-41">41</a> <a href="#L-42">42</a> <a href="#L-43">43</a> <a href="#L-44">44</a> <a href="#L-45">45</a> <a href="#L-46">46</a> <a href="#L-47">47</a> <a href="#L-48">48</a> <a href="#L-49">49</a> <a href="#L-50">50</a> <a href="#L-51">51</a> <a href="#L-52">52</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># Tip: Paste the following right below &#39;RewriteEngine on&#39; and do NOT change the order of rules </span><span id="L-2"><a name="L-2"></a># Notice: These rules may not work on websites using a CDN. In that case, you may want to use rules with hardcoded domains </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>########## CUSTOM RULES - START ########## </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a># File execution order </span><span id="L-7"><a name="L-7"></a>DirectoryIndex index.php index.html </span><span id="L-8"><a name="L-8"></a> </span><span id="L-9"><a name="L-9"></a># Added to prevent directory browsing </span><span id="L-10"><a name="L-10"></a>Options -Indexes </span><span id="L-11"><a name="L-11"></a> </span><span id="L-12"><a name="L-12"></a># Google Apps (replace domain.com with your domain, without the www portion) </span><span id="L-13"><a name="L-13"></a>Redirect 301 /mail http://mail.google.com/a/domain.com </span><span id="L-14"><a name="L-14"></a>Redirect 301 /docs http://docs.google.com/a/domain.com </span><span id="L-15"><a name="L-15"></a> </span><span id="L-16"><a name="L-16"></a># Or do the above automatically by uncommenting the 4 lines below and commenting the above 2 </span><span id="L-17"><a name="L-17"></a>#RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ </span><span id="L-18"><a name="L-18"></a>#RewriteRule ^mail[/]{0,1}$ http://mail.google.com/a/%2 [R=301,L] </span><span id="L-19"><a name="L-19"></a>#RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ </span><span id="L-20"><a name="L-20"></a>#RewriteRule ^docs[/]{0,1}$ http://docs.google.com/a/%2 [R=301,L] </span><span id="L-21"><a name="L-21"></a> </span><span id="L-22"><a name="L-22"></a># Redirect webmail.domain.tld to domain:2095 for cPanel Webmail only - COMMENTED by default </span><span id="L-23"><a name="L-23"></a>#RewriteCond %{HTTP_HOST} ^webmail\.(.+)$ [NC] </span><span id="L-24"><a name="L-24"></a>#RewriteRule ^(.*)$ http://%1/webmail/$1 [R=301,L] </span><span id="L-25"><a name="L-25"></a> </span><span id="L-26"><a name="L-26"></a># Redirect /index.php to / - will also clear /index.php/something to /something </span><span id="L-27"><a name="L-27"></a>RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/ </span><span id="L-28"><a name="L-28"></a>RewriteRule ^index\.php(/(.*))?$ /$2 [R=301,L] </span><span id="L-29"><a name="L-29"></a> </span><span id="L-30"><a name="L-30"></a># Redirect non-www to www - NOT COMMENTED by default </span><span id="L-31"><a name="L-31"></a>RewriteCond %{HTTP_HOST} !^www\. [NC] </span><span id="L-32"><a name="L-32"></a>RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] </span><span id="L-33"><a name="L-33"></a> </span><span id="L-34"><a name="L-34"></a># Redirect non-www to www - COMMENTED by default - use for FIXED domain </span><span id="L-35"><a name="L-35"></a>#RewriteCond %{HTTP_HOST} ^domain.com [nc] </span><span id="L-36"><a name="L-36"></a>#RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,L] </span><span id="L-37"><a name="L-37"></a> </span><span id="L-38"><a name="L-38"></a># Redirect www to non-www - COMMENTED by default </span><span id="L-39"><a name="L-39"></a>#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] </span><span id="L-40"><a name="L-40"></a>#RewriteRule ^(.*)$ http://%1/$1 [R=301,L] </span><span id="L-41"><a name="L-41"></a> </span><span id="L-42"><a name="L-42"></a># Compress text, html, javascript, css, xml, fonts </span><span id="L-43"><a name="L-43"></a>Addtype font/opentype .otf </span><span id="L-44"><a name="L-44"></a>Addtype font/truetype .ttf </span><span id="L-45"><a name="L-45"></a>AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript font/opentype font/truetype </span><span id="L-46"><a name="L-46"></a> </span><span id="L-47"><a name="L-47"></a># Allow Firefox to load fonts from different domains (e.g. a CDN location) </span><span id="L-48"><a name="L-48"></a>&lt;FilesMatch &quot;\.(woff|eot|svg|ttf)&quot;&gt; </span><span id="L-49"><a name="L-49"></a> Header set Access-Control-Allow-Origin * </span><span id="L-50"><a name="L-50"></a>&lt;/FilesMatch&gt; </span><span id="L-51"><a name="L-51"></a> </span><span id="L-52"><a name="L-52"></a>########## CUSTOM RULES - END ########## </span></pre></div> </td></tr></table>
apache, htaccess, redirects, rules