Tweak your .htaccess for Concrete5

I've made a few Concrete5 sites and is in general happy about it, but I've felt there where sometimes it was kinda slow. This, despite of the built-in cache functionality. I now know you can improve the performance quite a bit and also help your speed score at Google alot, meaning better ranking in search results.

Let me use an example from this site. I had two goals:

  1. Speed up the site
  2. Redirect acoon.dk to www.acoon.dk. Looks better for stats gathering and other stuff.

 

Speed it up

You should ofcourse enable the cache within concrete5, but you can also add a bit more that satisfy the browsers.

What you should do, is to add the following to the .htaccess file.

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
ExpiresActive On
ExpiresDefault "access plus 30 days"
FileETag none

This improved my performance alot.

 

One domain...

I also prefer to use only one domain for a website. The problem with allowing e.g. without the www, is that if you suddently change, you can experience that you are suddently logged out. This can confuse users, if you have any. :)

Look at line 5 and 6. Those are the important ones and is different than the standard Concrete5.

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. Options +FollowSymLinks
  4. RewriteBase /
  5. RewriteCond %{HTTP_HOST} !^www.acoon.dk$ [NC]
  6. RewriteRule ^(.*)$ http://www.acoon.dk/$1 [L,R=301]
  7. RewriteCond %{REQUEST_FILENAME} !-f
  8. RewriteCond %{REQUEST_FILENAME}/index.html !-f
  9. RewriteCond %{REQUEST_FILENAME}/index.php !-f
  10. RewriteRule ^(.*)$ index.php/$1 [L]
  11. </IfModule>

 

The whole file

Here is the entire file for easy copy.

<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.acoon.dk$ [NC]
RewriteRule ^(.*)$ http://www.acoon.dk/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule ^(.*)$ index.php/$1 [L]
 
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
ExpiresActive On
ExpiresDefault "access plus 30 days"
FileETag none
 
<Files .htaccess>
order allow,deny
deny from all
</Files>