Home » Blogging » How To » How to comment out lines in a .htaccess file

How to comment out lines in a .htaccess file

in How To

The .htaccess file is extremely powerful. It can be used to perform a whole range of tasks on an Apache web server.

One of the most important tasks it performs is to inform search engines that a particular file (which may be highly ranked with search engines) has been moved to another location – this is done by adding a “301 redirect” instruction to the .htaccess file.

I am currently in the process of housekeeping a website I run and need to move some of the files from one directory to another. This involves a whole load of 301 redirects being performed hy the .htaccess file. In order for me to keep track of the redirects I need to be able to add periodically add comments to the file. I wasn’t sure if it was possible to comment out lines in the .htaccess file, but a quick search on the internet has again provided me with the answer I need.

In order to comment out a line in a .htaccess just add the hash sign (#) to the start of the line, the details in that line will be ignored. This is the default .htaccess file created when WordPress is installed.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Dead easy and very useful.

  • Share/Bookmark

Other posts you might like to read

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: