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?


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:

/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess

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:

  • https://stackoverflow.com/questions/23198014/does-htaccess-rules-increases-load-time
  • https://www.quora.com/Will-too-many-lines-in-an-htaccess-file-slow-a-websites-load-time