Introduction to .htaccess files

A .htaccess file is a file on the apache server that controls how your visitors interact with your website. You can also block access to the server using this file. Basically, a htaccess file is a configuration file for apache based servers.

It is a very common file on the server. You might have come across this file if you have experience running CMS like WordPress, Drupal etc.

htaccess files have no names. They’re plain text files with the extension .htaccess. That is the reason it is hidden in the FileManager (all files that start with a dot are hidden by default in FileManager). If you’re unable to view them, you can either use an FTP client to check them, or you can enable hidden files in FileManager.

A htaccess file will control the directory that it lives in and the subdirectories within the directory (unless specified otherwise).

The below code is the default permalink code that is to be added (usually auto-set-up by WordPress itself) in the htaccess file for the proper functioning of WordPress permalinks:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Any line that starts with a # in htaccess is a considered a comment. If you would like to write one line note to help you remember what the code does, you can do so by adding # at the beginning of the line.

Editing htaccess files

If you’ve already enabled the option to show hidden files in FileManager and are still unable to view the htaccess file, it means the file is not yet created. If you would like to add any htaccess code and the file does not exist, you can simply create one in the root folder of your domain and add the necessary code inside the file.

One must be really careful while editing the htaccess files. A misconfiguration might lead to multiple issues, including your website going down.

You can either use the edit option in File Manager to edit the htaccess file or edit the file using an FTP client. Another option would be to download the htaccess file to your local computer using an FTP client and re-upload it after editing.

Please make sure the file name is .htaccess. Any other name and it would not work. If you’re on windows, you might need a third party editor like Notepad++ on order to edit this file and save it as .htaccess. If you do not have 3rd party editor, just upload the file as it is and then rename it using your FTP client

If the htaccess file you’re trying to edit has content in it, do not make any changes to it. Instead, just leave a line and then enter the code you’re trying to add in the next line.

/ /

Report (Please include link to post while reporting)

2 Comments on “ Introduction to .htaccess files ”

Leave a Reply

Your email address will not be published. Required fields are marked *