Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

hese's the my htaccess template, i wonder if anything could be added to increase website performance..

# Defaults
AddDefaultCharset UTF-8
DefaultLanguage en-US
ServerSignature Off
FileETag None
Header unset ETag
Options -MultiViews
#Options All -Indexes

# Force the latest IE version or ChromeFrame
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie

# Proxy X-UA Setup
<IfModule mod_headers.c>
Header append Vary User-Agent

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

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

# Redirect to WWW
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

# Redirect index to root
RewriteRule ^(.*)index\.(php|html)$ /$1 [R=301,L]

# Caching
ExpiresActive On
ExpiresDefault A0
Header set Cache-Control "public"

# 1 Year Long Cache
<FilesMatch "\.(flv|fla|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|png|jpg|jpeg|gif|swf|js|css|ttf|eot|woff|svg|svgz)$">
ExpiresDefault A31622400

# Proxy Caching
<FilesMatch "\.(css|js|png)$">
ExpiresDefault A31622400
Header set Cache-Control "private"

# Protect against DOS attacks by limiting file upload size
LimitRequestBody 10240000

# Proper SVG serving
AddType image/svg+xml svg svgz 
AddEncoding gzip svgz

# GZip Compression
<IfModule mod_deflate.c>
<FilesMatch "\.(php|html|css|js|xml|txt|ttf|otf|eot|svg)$" >
SetOutputFilter DEFLATE

# Error page
ErrorDocument 404 /404.html

# Deny access to sensitive files
<FilesMatch "\.(htaccess|ini|log|psd)$">
Order Allow,Deny
Deny from all
share|improve this question

Simple: move htaccess content to server config.

htaccess files are read & parsed each time a request to containing folder is done. On the other hand, server config is read only one time.

If you can't move these lines in httpd.conf, try to surround them in "Directory" tags, especially if some of these lines are linked to a specific directory.

share|improve this answer
just moving it to the config won't make it any faster.. He would have to disable the ability to look for .htaccess files.. The webserver will still spider the parent directories looking for a .htaccess file even if one is not there. – Mike Jan 7 '11 at 11:35
Yes, moving to httpd.conf is about resource usage & not delivery speed. – Pierre-Yves Gillier Jan 7 '11 at 11:40
seems clear, what about some other directives which can tune the website performance? – purpler Jan 8 '11 at 8:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.