Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to understand how .htaccess works. Can you give me some pointer, tutorials about how .htaccess works?

Also, the scripting language from htaccess file is 'interesting'. What is it about?

share|improve this question
up vote 5 down vote accepted

How .htaccess works is really quite simple. When you allow overrides to your configuration in the Apache config files, Apache will recursively look for .htaccess files in the document tree that leads to the requested file. If one is found, it's read and the Apache config statements in there will be treated as if they were located in the main config file. This allows users to add things like authentication and rewrite rules even if they are not allowed to modify Apache's config, and also without a restart. For more information, refer to the Apache doc, as Cian already suggested.

share|improve this answer
Don't you have to AllowOverride in your (virtual)host's definition in config files to allow .htaccess files to take effect? – Dan McClain Apr 22 '11 at 12:12
Yes, I even said so ('When you allow overrides'). – Sven Apr 22 '11 at 13:03
Ah, sorry, I missed that. – Dan McClain Apr 22 '11 at 13:17
Good answer, but one additional point. For the most part you can only use options that are valid in a <directory> context. You cannot change ports, setup ssl, or many other server-level things. – Zoredache Apr 22 '11 at 17:50

It's not a scripting language. It's the config language for apache. The apache docs are probably also your best place to learn about this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.