There are in general two possibilities of handling stuff on Apache:

  • make configurations for folders one by one using htaccess file

  • to fully resign htaccess and put all the rules into the httpd.conf

Usage of htaccess is a load time issue. I want to know, how expensive in terms of load time is htaccess usage? Are there any tests?


4 Answers 4


The recommendation from the Apache project is:

In general, you should only use .htaccess files when you don't have access to the main server configuration file. ... a common misconception is that user authentication and mod_rewrite directives must go in .htaccess files.

So please both set AllowOverride None and all your other directives in the main httpd.conf (and/or the subsections you Include)

When Apache is not configured with AllowOverride None you already occur a (minor) performance penalty, regardless of wether or not any .htaccess files are used.

This because for each and every request apache will need to check for the presence of a potential .htaccess file in every (sub-) directory leading down to the requested resource. For example when a file is requested out of a directory /www/htdocs/example, apache must look for the following files:


And so, for each file access out of that directory, there are 4 additional file-system accesses, even if none of those files are present. (If AllowOveride is set for /)

The system call used for that (man 2 stat) by itself isn't that expensive and typically the file-system cache is used rather than polling the actual disk, limiting the actual IO requirements, but still it can add up, as this article argues.

When one or more actual .htaccess files are actually present, apache still needs to open and read it (triggering another IO read operation and usually also an IO write operation to update the filesystem atime attribute) and parse it before the logic therein can be applied.

Unlike when your directives are in the main httpd.conf, which only needs apache to parse them once, at startup, each .htaccess file needs to be interpreted again for each and every request.

How expensive, in addition to the IO operations, parsing the .htaccess files is depends on their complexity.

That will take careful benchmarking to determine.


The expense depends upon how powerful the server is in particular it's storage I/O subsystem and whether there is any caching involved.

The way to test it is to configure your system with .htacess and load test it in the same way as you would any web server. Then configure the system without .htaccess and run the same tests.

Compare and contrast the results for your configured systems.


I don't believe there is a single right answer for your question. Are many variables which can affect htaccess load time:

  • Site folder structure: all .htaccess in each folders are loaded every time the page is open.
  • How long is the htaccess file: 200 lines vs 3500 lines? there is a big difference.
  • .htaccess configuration: rewrite and redirects rules can be more heavy than others (and are not the only ones).
  • The network connection in the client side can affect the load time. IMO, you may try it from more than one place and take the average time like a reference.
  • ab - Apache HTTP server benchmarking tool can help you

more info:


I have tested with and without .htaccess and could really find no difference in speed or overhead whatsoever. Granted I only run 16 sites and it's a super fast server so in my case tracking milliseconds is almost impossible. On a server running hundreds of sites the overhead may be noticeable so as @Iain said test and see.

I personally do everything using the .conf file for a virtual host and not the .htaccess it gives me absolute control over everything, it's cleaner and it's loaded once into apache's memory. Even my wordpress rewrite rules are in my .conf files so it can never break.

  • how fast is super fast? Jun 2, 2016 at 12:45
  • @James Kirkby I'll send you the exact server specs later, out of the office right now. I'm running everything in Proxmox containers. My web server and my 16 WordPress sites all have a 91-96 on Google Pagespeed and I'm always still tweaking and optimizing.
    – MitchellK
    Jun 2, 2016 at 13:00
  • @JamesKirkby It has 2 x 6 Core Processors and 64 Gb of Ram Running Ubuntu 14.04, Apache 2.4.7 and PHP-FPM. It's a little beast of note, I'm ecstatic with it's performance.
    – MitchellK
    Jun 3, 2016 at 9:35

You must log in to answer this question.

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