What Is the .htaccess File? Print

  • 0

The .htaccess file sits in your website folder and gives the server instructions, such as redirects, security rules and which pages to show. WordPress and many other apps create one automatically.

Finding It

  1. Open File Manager
  2. Click Settings and tick Show Hidden Files (dotfiles)
  3. Go to public_html. You'll see .htaccess if one exists

Before You Edit It

A single mistake can take your whole site offline with a 500 error. Always:

  1. Right-click .htaccess and choose Copy, naming the copy something like .htaccess-backup
  2. Make one change at a time
  3. Reload your site after each change

If something breaks, delete your edited file and rename the backup to .htaccess.

Useful Examples

Send Everyone to HTTPS

It's easier to turn on Force HTTPS Redirect in cPanel's Domains page. See Free SSL Certificates and HTTPS.

Redirect One Page

Redirect 301 /old-page https://yourdomain.com.au/new-page

For more redirect options, cPanel's Redirects tool writes the rules for you. See How to Redirect a Page or Domain.

Stop People Browsing Folder Contents

Options -Indexes

Don't Remove These

  • The # BEGIN WordPress to # END WordPress section, which WordPress needs
  • Lines added by cPanel, such as those that set your PHP version

Was this answer helpful?

« Back