Skip to content

Instantly share code, notes, and snippets.

@maranemil
Created December 10, 2014 09:41
Show Gist options
  • Save maranemil/9852c2b307438893bc21 to your computer and use it in GitHub Desktop.
Save maranemil/9852c2b307438893bc21 to your computer and use it in GitHub Desktop.
SugarCRM htaccess with new expires rules - boost speed
RewriteEngine on
# BEGIN SUGARCRM RESTRICTIONS
RedirectMatch 403 (?i).*\.log$
RedirectMatch 403 (?i)/+not_imported_.*\.txt
RedirectMatch 403 (?i)/+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*\.(php|tpl)
RedirectMatch 403 (?i)/+emailmandelivery\.php
RedirectMatch 403 (?i)/+upload/
RedirectMatch 403 (?i)/+custom/+blowfish
RedirectMatch 403 (?i)/+cache/+diagnostic
RedirectMatch 403 (?i)/+files\.md5$
# Fix mimetype for logo.svg (SP-1395)
AddType image/svg+xml .svg
AddType application/json .json
AddType application/javascript .js
<IfModule mod_rewrite.c>
Options FollowSymLinks Indexes
# +SymLinksIfOwnerMatch +ExecCGI +FollowSymLinks +MultiViews +Indexes
RewriteEngine On
RewriteBase /PhpstormProjects/sugarcrm
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^rest/(.*)$ api/rest.php?__sugar_url=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cache/api/metadata/lang_(.._..)_(.*)_public(_\w*)?\.json$ rest/v10/lang/public/$1?platform=$2&ordered=$3 [N,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cache/api/metadata/lang_(.._..)_([^_]*)(_\w*)?\.json$ rest/v10/lang/$1?platform=$2&ordered=$3 [N,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cache/Expressions/functions_cache(_debug)?.js$ rest/v10/ExpressionEngine/functions?debug=$1 [N,QSA]
</IfModule>
<IfModule mod_mime.c>
AddType application/x-font-woff .woff
</IfModule>
#<FilesMatch "\.(jpg|png|gif|js|css|ico|json|js|html|txt|xml|woff|htm)$">
<IfModule mod_headers.c>
#Header set ETag ""
Header append Cache-Control "public"
Header set Cache-Control "max-age=2592000"
Header set Expires "01 Jan 2112 00:00:00 GMT"
Header unset ETag
FileETag None
</IfModule>
#</FilesMatch>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 1 month"
# Document html
ExpiresByType text/html "access plus 30 seconds"
# Data
ExpiresByType application/json "access plus 1 hour"
ExpiresByType application/xml "access plus 1 hour"
ExpiresByType text/xml "access plus 1 hour"
# Webfonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
# CSS and JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
# Original Sugar Rules
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
</IfModule>
# END SUGARCRM RESTRICTIONS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment