KNOWNHOST KNOWLEDGE BASE

Hosting Question? Find the Solution - Browse our Guides, Articles, and How-To's

How to modify the .htaccess file?

Category: Guides
Tags: # # # #

The .htacceess files provide the way to perform the configuration on a per-directory basis. In this article, we will cover how to modify the .htaccess files on cPanel, DirectAdmin, and using SSH. Let’s get started!


Using cPanel

1. Log in to cPanel using Username Password. i.e; (https://yourdomain.com:2083 or https://yourdomain.com/cpanel)

2. Navigate and open Files → File Manager.

3.  Navigate to public_html.

4. Select the .htaccess file → Click on Edit. If you cannot find the .htaccess file, that is probably because the “Show Hidden File” option must be disabled. To enable the hidden files, follow this article.

select htaccess file click on edit

5. In another tab, the editor will open, enabling the access to edit the .htaccess file. Once the required changes are made, click on SAVE.

how to edit htaccess file using cpanel

Using DirectAdmin

1. First, to login into DirectAdmin control panel visit, 

https://your-domain.com:2222 or https://IP-address:2222 or https://server-hostname:2222.

login-into-directadmin

2. Navigate to System Info & Files → File Manager.

navigate-to-file-manager-directadmin

3. Navigate to public_html.

navigate to public_html directadmin

4. Select the .htaccess file → Click on Edit.

right click on htaccess file click on edit directadmin

5. Once the changes are made, click on Save File.

how to edit htaccess in directadmin

Using SSH

Except GUI method SSH method requires slight SSH knowledge to perform the modification in .htaccess file. In this sectiom, you will learn about to how to view/edit dot/hidden files using SSH.

To view hidden/dot files using following command,

ls -a
search hidden dot files using ssh

To edit the .htaccess file you can take the help of any text editor (vi, vim, nano, etc.). For this article, we will use vi text editor,

vi .htaccess
edit the htaccess file with vi editor

To save the changes and exit, Press Esc → type :wq! (w= write, q=quit, !=force).

how to edit htaccess file using ssh

Conclusion

Now that we’ve gone over how to modify the .htaccess file using cPanel, DirectAdmin, and SSH. This one-stop article will guide you through the step-by-step procedure to modify the .htaccess file.

KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team is ready to help you with requests should you need our assistance. You’re not using KnownHost for the best web hosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your web hosting experience.