An .htaccess file contains directory-level settings used by Apache, such as redirects and access rules. This guide explains how to create the file in cPanel when your website does not already have one.

Check for an existing file

  1. Log in to cPanel and open Files > File Manager.
  2. Open Settings, select Show Hidden Files (dotfiles) and save.
  3. Browse to the website’s document root. This may be public_html or another directory shown in cPanel’s Domains page.
  4. Look for .htaccess. If it exists, download a backup and edit the existing file instead of replacing it.

Create the file

  1. In the required directory, click + File.
  2. Enter .htaccess as the filename, including the leading dot.
  3. Check the destination path and click Create New File.
  4. Select the file and click Edit to add the rules your website requires.
  5. Save and test the affected pages. If a change causes an error, remove that change or restore your saved copy.

create a new .htaccess file