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

Learn how to edit .htaccess with Plesk, cPanel, or the Linux command line.

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.

  2. Open the File Manager:

    • If you are using the Jupiter theme, on the Tools page, in the Files section, click File Manager:
      cPanel - File Manager icon (Jupiter theme)

    • If you are using the Paper Lantern theme, in the FILES section of the cPanel home page, click File Manager:
      cPanel - File Manager icon

  3. Click on 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.

  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.

  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.

  8. Right-click on the.htaccess file in the right-hand pane of File Manager and select Edit from the pop-up menu.

  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.

  11. Click Save Changes at the upper right of File Manager.

  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.

  1. Log in to Plesk.

    📘

    Note

    If you do not know how to log in to your Plesk account, please see this article.

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

  3. Click on the File Manager icon.

  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.
    Plesk File Manager Settings

  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.

  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.

  9. Click the name of the file to open it in the editor.

    🚧

    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.

    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.

  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.

  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
    nano httpdocs/.htaccess
    
    • For cPanel
    nano public_html/.htaccess
    
    • For unmanaged servers
    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.

  4. Press Ctrl + O to write out the file. Make sure the File Name to Write is.htaccess. Press Enter.

  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