Hacker News new | past | comments | ask | show | jobs | submit login

Came here just to say that, you beat me to it. htaccess files are performance-crippling crutches for allowing config access in limited shared hosting environments. If you own the server, never use them. For performance reasons nginx doesn't even have a similar concept.

One interesting thing to note is that every Apache config file will (or should have!) some lines like this in it:

  <Directory />
    AllowOverride None
  </Directory>
If this is not there, Apache will look for a .htaccess file in every single folder starting at '/' all the way up to your document root and on into the folder of the URL being requested e.g.

Your document root is here: /very/long/path/to/your/webroot

You request the following URL: "/project/files/here/file.html", which servers this file: /very/long/path/to/your/webroot/project/files/here/file.html

Without the above config settings, Apache would attempt to stat the following files each time the url "/project/files/here/file.html" is requested...

  /.htaccess
  /very/.htaccess
  /very/long/.htaccess
  /very/long/path/.htaccess
  /very/long/path/to/.htaccess
  /very/long/path/to/your/.htaccess
  /very/long/path/to/your/webroot/.htaccess
  /very/long/path/to/your/webroot/project/.htaccess
  /very/long/path/to/your/webroot/project/files/.htaccess
  /very/long/path/to/your/webroot/project/files/here/.htaccess
Ouch!

If you have the above mentioned config in place (it's part of most default apache configs, but I have seen mis-configured servers without it), but you allow override for your webroot, you will still have the following file stats to perform for the same URL request:

  /very/long/path/to/your/webroot/.htaccess
  /very/long/path/to/your/webroot/project/.htaccess
  /very/long/path/to/your/webroot/project/files/.htaccess
  /very/long/path/to/your/webroot/project/files/here/.htaccess
Which is still rather wasteful if not absolutely necessary. Only use .htaccess files when no other option is available.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: