1

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
</IfModule>
</IfModule>


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


#Rewrites
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} ^domain.com
RewriteRule (.*) http://www.domain.com/$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
</FilesMatch>

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


# 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
</FilesMatch>
</IfModule>


# Error page
ErrorDocument 404 /404.html


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

1 Answer 1

3

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.

3
  • 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, 2011 at 11:35
  • Yes, moving to httpd.conf is about resource usage & not delivery speed. Jan 7, 2011 at 11:40
  • seems clear, what about some other directives which can tune the website performance?
    – dzhi
    Jan 8, 2011 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .