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 / https://www.iftekhar.net/

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.

Today In History

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from HTMLify, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.