How to edit your .htaccess file Print

  • 0

The .htaccess file contains directives (instructions) that tell the server how to behave in certain scenarios and directly affects how your website functions. Redirects and rewriting URLs are two very common directives found in an .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.

There are many ways to edit an .htaccess file.

1] Edit the file on your computer and upload it via FTP client like FileZilla, CoreFTP, CuteFTP, etc.

2] Use an FTP program's "Edit" mode that allows you to edit a file remotely.

3] Use the File Manager in cPanel to edit the file.

The fastest and easiest way to edit an .htaccess file for most people is to use the File Manager in cPanel.

To edit .htaccess file in cPanel's File Manager,do the following:

Before making the changes,it is suggested that you backup your website so that you can revert back to a previous version if something goes wrong.

1. Login to the cPanel.

2. Under Files section,click on File Manager.

3. Choose the option Document Root for and select the domain name you wish to access.

4. Make sure Show Hidden Files (dotfiles) is checked and then click the Go button.

5. Look for the .htaccess file in the list of files. You may need to scroll to find this file.

6. Right click on the file and click on Code Editor on the menu. (Alternatively, you can click on the icon for the .htaccess file and then click on the Code Editor icon from the top toolbar).

7. A dialogue box may appear asking you about encoding. Just click on the Edit button to continue. The editor will open in a new window.

8. Edit the file as needed.

9. Click on the Save Changes button in the upper right hand corner when done.
The changes have been saved. Test your website to make sure it has the desired effect. If not, correct the error or revert back to the previous version until your site works again.

10. Once complete, you can click Close to close the window.


Was this answer helpful?

« Back