> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Editing .htaccess files with Plesk, cPanel, or the command line

> Learn How to Edit .htaccess with Plesk, cPanel or Linux Command Line. Our Step-By-Step Guide Makes It Easy!

The *.htaccess* file is the local Apache settings document that instructs the Apache web server how to work with your website. Many useful and interesting things are possible with the settings inside *.htaccess*, but first you must know how to create and edit an *.htaccess* file. This article shows you how.

See the Related Articles section to see some of the things you can do with *.htaccess* once you have learned to create and edit the file.

## Using the cPanel File Manager

1. Log in to cPanel.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. On the **Tools** page, in the **Files** section, click **File Manager**:\
   ![](https://static.hosting.com/kb/kb-cpanel-jupiter-file-manager-icon.png)

3. Click the **public\_html** folder in the left panel of the File Manager. Files in public\_html are shown in the right panel.

4. If the .htaccess file is not visible, click the **Settings** button at the upper right of the File Manager.![](https://static.hosting.com/kb/kb-cpanel-filemanager-settings-button.png)

5. In the pop-up dialog box, make sure **Show Hidden Files (dotfiles)** is checked. If it is not checked, check the box and then click **Save**.\
   ![](https://static.hosting.com/kb/kb-cpanel-filemanager-settings-dialog.png)

6. If there is still no .htaccess file visible, click the **+ File** button in the File Manager toolbar.

7. In the pop-up dialog box, enter.htaccess for the file name and click the **Create New File** button. You should now be able to see the .htaccess file in File Manager.![](https://static.hosting.com/kb/kb-cpanel-filemanager-newfile-dialog.png)

8. Right-click on the .htaccess file in the right-hand pane of File Manager and select **Edit** from the pop-up menu.\
   ![](https://static.hosting.com/kb/kb-cpanel-filemanager-contextmenu.png)

9. Click the **Edit** button on the pop-up dialog box.

10. Make any desired additions or changes to the file in the editing area.![](https://static.hosting.com/kb/kb-cpanel-filemanager-editor.png)

11. Click **Save Changes** at the upper right of File Manager.\
    ![](https://static.hosting.com/kb/kb-cpanel-filemanager-savechanges-button.png)

12. Visit the site to make sure everything works as expected.

13. Go back to the editor and make corrections or additional changes if needed. The cPanel editor has an undo feature so you can easily roll back any changes.

14. After your changes are complete, click **Save Changes** to save any changes and then click **Close** to close the editor.

## Using the Plesk File Manager

<Note>
  Plesk is used for the Managed WordPress hosting plan which run on Linux operating systems. These instructions only work for Linux-based installations.
</Note>

1. Log in to Plesk.
   > 📘 Note
   >
   > If you do not know how to log in to your Plesk account, please see [this article](/docs/logging-in-and-out-of-plesk).

2. If there is more than one domain, scroll to the management area for the desired domain.

3. Click on the **File Manager** icon.\
   ![](https://static.hosting.com/kb/kb-plesk-file-manager-icon.png)

4. The File Manager will open up to the root directory for the domain selected.

5. If the .htaccess file is not visible, click the **Settings** button at the upper right of the File Manager.

6. In the pop-up dialog box, make sure **Show system files and directories** is checked. If it is not checked, check the box and then click **OK**.\
   ![](https://static.hosting.com/kb/kb_htaccess_filemanagerplesk.PNG)

7. If there is still no .htaccess file visible, click the **New** button in the File Manager toolbar and select **Create File** from the drop-down list.\
   ![](https://static.hosting.com/kb/kb-plesk-filemanager-createfile.png)

8. In the pop-up dialog box, enter **.htaccess** for the file name and click **OK**. You should now be able to see the .htaccess file in File Manager.\
   ![](https://static.hosting.com/kb/kb-plesk-filemanager-createfile-dialog.png)

9. Click the name of the file to open it in the editor.![](https://static.hosting.com/kb/kb-plesk-filemanager-htacces.png)

   > 🚧 Important
   >
   > The Plesk editor does not have an undo feature. If you are not confident in your editing skills, follow these instructions to make a backup:
   >
   > 1. Click the **Save As** button at the bottom of the editor to create a backup copy of the file.\
   >    ![](https://static.hosting.com/kb/kb-plesk-filemanager-saveas-dialog.png)
   >
   > 2. Give the backup a name in the **Save As** dialog and click **OK**. The editor will close.
   >
   > 3. Click on .htaccess again to re-open it.

10. Make any desired additions or changes to the file in the editing area.\
    ![](https://static.hosting.com/kb/kb-plesk-filemanager-editor.png)

11. Click the **Apply** button at the bottom of the editor.

12. Visit the site to make sure everything works as expected.

13. Go back to the editor and make corrections or additional changes if needed.

14. Click **OK** to save the changes and close the editor.

## Using the command line

1. Log into the account to be modified using SSH.
   > 📘 Note
   >
   > If you do not know how to use SSH, please see [this article](/docs/using-ssh-secure-shell).

2. Edit the .htaccess file using the Nano editor by entering the appropriate command below. If the file exists it will be opened. If the file does not exist, it will be created.

   * For Plesk

   ```bash theme={null}
   nano httpdocs/.htaccess
   ```

   * For cPanel

   ```bash theme={null}
   nano public_html/.htaccess
   ```

   * For unmanaged servers

   ```bash theme={null}
   nano /var/www/html/.htaccess
   ```

   > 🚧 Important
   >
   > The command lines above show common locations for the websites to be stored for the various platforms. Your site may be in another location. Change the path accordingly.

3. Once the file is open, make any desired additions or changes to the file in the editing area.![](https://static.hosting.com/kb/kb-htaccess-nano-editor.png)

4. Press **Ctrl + O** to write out the file. Make sure the **File Name to Write** is .htaccess. Press **Enter**.![](https://static.hosting.com/kb/kb-htaccess-nano-filenametowrite.png)

5. Visit the site to make sure everything works as expected.

6. Go back to the editor and make corrections or additional changes if needed.

7. After your changes are complete, press **Ctrl + O** to write out the file. Make sure the **File Name to Write** is .htaccess. Press **Enter**.

8. Press **Ctrl + X** to exit Nano.

## Related articles

* [Using .htaccess files](/docs/using-htaccess-files)

* [Redirecting visitors to SSL connections](/docs/redirecting-users-to-ssl-connections)

* [Using www and non-www domains with an SSL certificate](/docs/using-www-and-non-www-domains-with-an-ssl-certificate)

* [Data compression using the mod\_deflate module](/docs/data-compression-using-the-mod-deflate-module)

* [Default directory index page](/docs/default-directory-index-page)

* [Directory index listings](/docs/directory-index-listings)

* [Adding or removing the www prefix in domain URLs](/docs/adding-or-removing-the-www-prefix-in-domain-urls)

* [Rewriting URLs with the mod\_rewrite module](/docs/rewriting-urls-with-the-mod-rewrite-module)

* [Using the mod\_speling Apache module](/docs/using-the-mod-speling-apache-module)

* [Configuring caching with the mod\_expires module](/docs/configuring-caching-with-the-mod-expires-module)
