Is there a way to write notes in htaccess file?

Is there a way to write notes in .htaccess file like we do in html or css files? If yes how?

Yes, start the line with a #

:slight_smile:

Yes. If they are just on one line, you can just put // at the start of the line to make it a comment.

If your comment goes over multiple lines, I believe you can wrap those lines in /* */ (like PHP and CSS) but test this out rather than taking my word for it, as I’m not sure if it works in all circumstances. :slight_smile:

Edit:

Beaten to it—no doubt with a better answer!

Is this how its done # Redirect 301 /example.html http://www.domain.com/example.html

Make sure the line starts with the # (no words before it, like you have).

The easiest way to be sure is to test it on your htaccess file.

thanks i’ll try now

works great thanks

For reference, // and /* */ do NOT work in .htaccess. only #

Eek, thanks Remon. DK mentions them in his notes, so I obviously misread the purpose of them. :frowning:

SES & Ralph,

That (# anywhere on the line will render anything following it as a comment) was the best answer for a one-liner but you can comment out an entire block of mod_rewrite code using the RewriteEngine on|off directive. Obviously,

RewriteEngine on
# bunch of mod_rewrite code - enabled by the 'on'

RewriteEngine off
any [B][I]mod_rewrite code[/I][/B] which needs to be disabled
RewriteEnging on

# return to mod_rewrite processing

The only warning I can provide is that the RewriteEngine directive is specific to mod_rewrite code processing so don’t use it to comment out Apache directives!

Yes, I get too focused on mod_rewrite but this is a very useful way to comment out mod_rewrite code.

Regards,

DK

Cool, thanks DK. Now I have to learn to distinguish between the two. :slight_smile: