.htaccess and Mod Rewrite

If you are not a developer who is familiar with working on Apache, you have more than likely not heard of a .htaccess file. But, if you ever decide to get a website, you may get stuck listening to some web developer lingo, so we’re just sharing some of that lingo for you.

What is a .htaccess file?

Htaccess = hypertext access file.

The .htaccess file is a simple ASCII file that can be edited using Wordpad or even Notepad. The file allows developers or webmasters to implement single command lines in the file that the webserver, Apache, understands and uses to do various tasks.

What is .htaccess used for?

The most popular command lines that are implemented are:

  • Authentification or Access control – .htaccess can stop certain IP ranges from accessing your page and with the use of a .htpasswd can force people to have to log into a website before gaining access to the website’s info.
  • Customising error messages – .htaccess files allow you to redirect to a specific URL / website address when a particular error occurs e.g. a page not found
  • Rewriting URLs – this can be quite an interesting and at times challenging feature implementing into .htaccess files. Rewriting URLs simply means taking a URL and redirecting it to the same page using a different URL. Sounds fancy hey? Well, it’s a great tool to have and is especially useful for websites that are database driven.

Summary

So, there you have it – a brief introduction to the .htaccess file. There is loads of info available online about .htaccess so if this sounds interesting to you, then do a search and research it a little more.