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 SiveHost Shared, Reseller, SEO*, 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.
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

PHP Memory Limit Error

Allowed Memory Size Exhausted Errors Fatal error: Allowed memory size of 12582912 bytes...

PHP Versions

PHP 5.3 for Linux Shared and Reseller Hosting PHP 5.3 is not the default version on all Linux...

30 Things to Do After Minimal RHEL/CentOS 7 Installation

12. Install Apache Tomcat Tomcat is a servlet container designed by Apache to run Java HTTP web...

What is SiveHost Dedicated Hosting?

SiveHost’s Dedicated Hosting servers is the ideal solution for larger businesses and high-traffic...

What is Managed Dedicated hosting?

A Managed Dedicated Hosting server is when a client has an entire web server specifically...