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 A felhasználók hasznosnak találták ezt
Hasznosnak találta ezt a választ?

Kapcsolódó cikkek

How to Reset cPanel's Account Password

If you have access to your cPanel account, follow these steps to reset your password:1. Log in to...

How to Change cPanel's Style/Theme

Switching over to another cPanel theme with a different style is easy.1. Log in to your cPanel...

How to Create a Cronjob in cPanel

1. Log in to your cPanel account. 2. In the Advanced section, click on Cron Jobs. 3. Under Add...

How to Update a Cronjob Email Address in cPanel

You can enable cronjob notifications or update a cronjob's email address in cPanel. 1. Log in to...

How to Reset the PHP Version to the Default Version in cPanel

If you want to reset the PHP version to the default version, follow these instructions:1. Log in...