How to Make A Comment in .htaccess

Comments are super important, especially in a large file. They help you remember what a specific chunk of code does, so you, or someone else, are able to quickly understand the file when looking at it on a later date.

So how do you make a comment?

Commenting is super simple, just follow these two rules!

  1. A comment must be on its own line
  2. A comment must start with a pound sign (Or hash character) “#”

What are some examples?

Example One:

ErrorDocument 404 /error/404.html
# Hi! I am a super comment!!!
ErrorDocument 403 /error/403.html

Example Two

##########
#READ ME!
###########
ErrorDocument 403 /error/403

Advertisement

What are some invalid examples?

Don't copy this one!

Bad example:

ErrorDocument 401 /error/401
ErrorDocument 404 /error/404 #Not here!

Conclusion

That's it! Super simple, but you will thank yourself when it saves you time in the future. Happy coding!

Advertisement

Article Author

Related Articles

Deny Access to Hidden Files with .htaccess

Is your website ready to go live? It’s always a good idea to block people from accessing files they shouldn't, like your .htaccess file for example! This code will block access to any files beginning ...

Advertisement

All code and content © 2024. Contact Us to learn more.