How to Edit your .htaccess file

The .htaccess file contains directives (instructions) that tell the server how to behave in certain scenarios and directly affect how your website functions.

Redirects and rewriting URLs are two very common directives found in a .htaccess file, and many scripts such as WordPress, Drupal, Joomla and Magento add directives to the .htaccess so those scripts can function.

It is possible that you may need to edit the .htaccess file at some point, for various reasons.This article covers how to edit the file, but not what to change. (You may need to consult other articles and resources for that information.)

There are Many Ways to Edit a .htaccess File

  • Edit the file on your computer and upload it to the server via FTP
  • Use an FTP program's Edit Mode
  • Use SSH and a text editor
  • Use the File Manager in cPanel

The fastest and easiest way to edit a .htaccess file for most people is to use the File Manager in cPanel; this article covers how to edit using this method and applies to Linux web hosting, such as Digicom Shared, Reseller, VPS and Linux Dedicated Servers.


How to Edit .htaccess in cPanel's File Manager

Before we do anything, it is suggested that you backup your website so that you can revert back to a previous version if something goes wrong.

To Open the File Manager

  1. Log into cPanel.
  2. In the Files section, click on the File Manager icon.
  3. Check the box for Document Root for and select the domain name you wish to access from the drop-down menu.
  4. Make sure Show Hidden Files (dotfiles)" is checked.
  5. Click Go. The File Manager will open in a new tab or window.
  6. Look for the .htaccess file in the list of files. You may need to scroll to find it.

To Edit the .htaccess File

  1. Right click on the .htaccess file and click Code Edit from the menu. Alternatively, you can click on the icon for the .htaccess file and then click on the Code Editor icon at the top of the page.
  2. A dialogue box may appear asking you about encoding. Just click Edit to continue. The editor will open in a new window.
  3. Edit the file as needed.
  4. Click Save Changes in the upper right hand corner when done. The changes will be saved.
  5. Test your website to make sure your changes were successfully saved. If not, correct the error or revert back to the previous version until your site works again.
  6. Once complete, you can click Close to close the File Manager window.
Note: Instead of using the cPanel method, many people find changing the .htaccess file via FTP or SSH an easy alternative.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

WordPress pointing home URL to subdirectory

Pointing your home site's URL to a subdirectory In some cases, you may have a WordPress site...

How to log into cPanel

cPanel is a web hosting account management tool available on all Digicom Linux hosting plans,...

Change cPanel Password or recover lost password

Requesting a New cPanel Password If you have lost or forgotten your cPanel password, you can...

Location of Script Configuration Files

Location of Script Configuration Files These paths are relative to the root of the script, not...

Connect to MySQL Database

How to Connect to the MySQL Database In order for your MySQL database to work as intended, it...