# 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 ##########