I only have a basic understanding of .htaccess files. What are some tasks that can be accomplished using them? What are good resources that would aid in learning how to use them on a more advanced level? What are downsides/risks/etc to using them? What are benefits to using them?

  • 1
    This is still way too broad. If you want to learn about .htaccess Google it. If you then have any specific questions come back and ask them here.
    – John Conde
    Mar 12, 2011 at 1:32
  • Sometimes its nice to get input from people with experience before doing research. Saves a lot of time and would be useful for others.
    – Kenneth
    Mar 12, 2011 at 2:00
  • Unfortunately that doesn't meet the requirements set forth in the faq
    – John Conde
    Mar 12, 2011 at 2:03
  • Other SE's don't seem to have a problem with it.
    – Kenneth
    Mar 12, 2011 at 2:05
  • I disagree. I see vague questions like this closed at StackOverflow all the time. Either way, it still doesn't meet the criteria set forth in this FAQ which is what matters.
    – John Conde
    Mar 12, 2011 at 2:24

1 Answer 1


.htaccess (hypertext access) files are essentially a per-directory Apache configuration file. Whatever configuration options you put in that file will apply only to the contents of that directory including its sub-directories.

What you can do with htaccess files depends on how your specific Apache install is configured. Generally, you can use set, for instance PHP runtime flags, as well as control viewing permissions, password protection, directory indexes, and rewriting urls.

Apache's online documentation has a great tutorial to .htaccess files.

The risk of using an .htaccess file is misconfiguration. If you cause a syntax error in an .htaccess file, Apache will throw HTTP 500 errors to the client making your directory and everything under it impossible to access via web. There is no official .htaccess syntax validator that I'm aware of but you can try this one.

There are tons of great benefits to using .htaccess files. Because they are called on every request they apply to (which could turn into a performance issue for some), configuration takes place immediately and you don't have to reload or restart Apache. They are ideal for, and often used on, shared web-hosting because you won't have access to Apache's main configuration file(s).


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