4

Will turning off override by htaccess in apache have a performance increase? I have had a look online and there is very little articles/reports on this.

If this is the case how do I go about turning this off? Will I do this in the default virtual host file?

A example being: OpenCart comes with 2 htaccess files mainly for mod_rewrite, if I move this into a <Directory> will this make a difference?

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName shop.co.uk
    ServerAlias www.shop.co.uk
    DocumentRoot /var/www/shop/public

    <Directory /var/www/shop/public>
        Options +FollowSymlinks

        # Prevent Direct Access to files
        <FilesMatch "\.(tpl|ini|log)">
         Order deny,allow
         Deny from all
        </FilesMatch>

        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
    </Directory>

    <Directory /var/www/shop/public/admin/view/javascript/ckeditor>
        AddType application/x-javascript .js
        AddType text/css .css

        # If PHP is mapped to handle XML files, you could have some issues. The following will disable it.
        AddType text/xml .xml
    </Directory>

    ErrorLog /var/log/apache2/shop-error.log
    LogLevel warn
    CustomLog /var/log/apache2/shop-access.log combined
</VirtualHost>

1 Answer 1

10

Apache won't need to look for a .htaccess file every time it accesses a file. The actual performance benefit will depend on,

  1. traffic to your site
  2. site layout
  3. server profile

I suggest you baseline the existing performance, using a web stress tool such as Apache's ab, make the change, re-profile, and see how much impact it has.

As to your second question, yes, I believe you would move the .htaccess stuff into <Directory> sections in your <VirtualHost>.

2
  • 3
    Another thing to note is it'll search every parent directory for an .htaccess file - deeper directories mean more checks (on every request). AllowOverride None to disable completely. Sep 10, 2011 at 20:21
  • 1
    As an alternative to ab you might use joedog.org/index/siege-home
    – weeheavy
    Sep 12, 2011 at 14:11

You must log in to answer this question.

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