Knowledgebase

How to insert comments and comment out directives in .htaccess files

In the .htaccess files on your hosting account you can put comments, and you can comment out directives and uncomment directives that are commented out. All this is done with the number symbol #. Generally, each directive is placed on a new line in .htaccess files. When the line begins with the symbol # it's considered a comment.

This can be used to put explanations and notes about the different directives. For example, in the following:

#Set the default index page to index.php
DirectoryIndex index.php

the first line is just a comment explaining what the directive is for, and the second line is the actual directive.

If you put the number symbol # in front of a directive, then the directive will not be applied. In the following example:

#Set the default index page to index.php
#DirectoryIndex index.php

the DirectoryIndex directive is inactive. In case you need the directive to be active you just have to remove the # from the beginning of the line.

Was this answer helpful?

 Print this Article

Also Read