How to Add Comments on a .htaccess File

On this site I wrote number of posts on .htaccess and I am expecting to write lot more on up coming days. Part of the reason behind this is, there are lots of things that can be done with .htaccess configuration file on Apache web server. Starting from redirecting users to custom error page to securing your site, .htaccess can really make a developer's life lot simpler.

Now as you start piling up various rules on .htaccess file, you might find it necessary to organize them or to write a comment before every single rules so that whoever works on this site in the future can easily understand what exactly is going on. All you need to do is simply add a "#" (hash) symbol before your comment line. Here is an example of such line.

# Simply redirect all of my old homepage traffic to my new homepage
RewriteEngine On
Redirect 301 /

This is as simple as it can get. If you want add multiple line comments, simple add more # (hash) symbol before the beginning of each line. You are all set.


Commenting is disabled.