How to Edit the .htaccess File in cPanel Print

  • 0

The .htaccess file controls how the web server handles requests for your site: redirects, HTTPS, access rules and more. This article shows you how to find and safely edit it in cPanel's File Manager.

Edit .htaccess

  1. Log in to cPanel and open Files › File Manager.
  2. Click Settings (top right), tick Show Hidden Files (dotfiles) and click Save. Without this, the file won't appear.
  3. Open public_html for your main domain, or the document root of an addon domain or subdomain. Each folder can have its own .htaccess.
  4. Make a backup first: right-click .htaccess, choose Copy, and save it as something like .htaccess.bak.
  5. Right-click .htaccess and choose Edit, then click Edit again in the encoding prompt.
  6. Make your changes and click Save Changes.
  7. Reload your website in a private window to check it still works.

If there's no .htaccess file yet, click + File, name it .htaccess (with the leading dot) and create it in the right folder.

If something goes wrong

A 500 Internal Server Error after saving almost always means there's a typo in the file. Delete the lines you just added, or delete the edited file and rename .htaccess.bak back to .htaccess. Your site should return straight away.

On WordPress sites, keep your own rules outside the # BEGIN WordPress … # END WordPress block. WordPress overwrites that section.

Common uses


Was this answer helpful?

« Back