Friday, April 17, 2009

About .htaccess

Here are a few things to keep in mind about .htaccess files:

  • There are no tags to enclose them. No start tags, no end tags.
  • Upon uploading your .htaccess file, it will affect everything in that directory and in deeper directories, so be careful.
  • The file is usually hidden in the Linux Shell. If you're new to this, you might want to find it via a program like WinSCP or by FTPing and enabling the viewing of hidden files in your FTP client.
  • Error 500 can often be explained by a bad .htaccess file. If you get this error while working on your .htaccess file or shortly thereafter, check to make sure everything is correct.
  • .htaccess files override the rules set forth by .htaccess files in higher directories.
  • This is how you write a comment:
    • # Lines starting with a pound symbol are comments!

  • This is how you do a 301 redirect:
    • redirect 301 / myotherpage.cgi


  • The commands in your .htaccess file are called "directives"