tags:

views:

28

answers:

2

Hi,

in a product I'm fighting with, I found an .htaccess file at the application root, which basically rewrites requests to non-existing files to a central processing script.

For performance reasons I now want to move that rule to my server (virtual host) configuration.

The simplest way to do it is to literally copy the rules into a <Directory> section, as these get interpreted just like .htaccess contexts, right? Well - it works.

Would I have any benefit from modifying the rules and moving them to server/toplevel context instead of a directory context?

EDIT: I seem to not have been clear enough. By 'directory context' I do NOT mean a .htaccess file, but a <Directory> section within my server configuration file.

A: 

The server configuration file is only read and parsed once when the server is started. But .htaccess files read and parsed every time a request is done. Furthermore any .htaccess file on the way down to the directory where the requested file is located are read an parsed. If you have a structure like this:

htdocs/
  foo/
    .htaccess
    bar/
      .htaccess
      baz/
        .htaccess
        somefile.html

And you would request /foo/bar/baz/somefile.html, all the .htaccess files the file hierarchy down to somefile.html are parsed and parsed. Now you can imagine on your own if that’s an overhead or not.

Gumbo
A: 

Here's an interesting blog post about that:

http://www.fubra.com/blog/2008/01/htaccess-vs-httpdconf/

Seems they concluded that it's only about 6.6% faster to have the rules in httpd.conf

So you get a bit of a performance gain, but you also give up some flexibility to change rules per directory or without restarting the server.

Eric Petroelje