How to do common tasks with .htaccess

Stop folder listings, prevent image hotlinking, protect .htaccess and create simple friendly URLs.

Updated September 27, 20261 min read

The .htaccess file in your website folder controls how the web server handles your site. A single mistake can stop your website loading, so make a copy before you edit it.

Find and edit .htaccess

  1. Open File Manager in cPanel.
  2. Click Settings (top right), tick Show Hidden Files (dotfiles) and click Save.
  3. Open public_html, right-click .htaccess and choose Edit. If there isn’t one, click + File to create it.

Stop folder listings

If a folder has no index file, the server may show a list of its files. Add this line to stop that:

Options -Indexes

You can also do this without editing any files in cPanel’s Indexes tool, in the Advanced section.

Stop other websites using your images

“Hotlinking” is when another site shows your images using your bandwidth. The easiest fix needs no code: in cPanel’s Security section, open Hotlink Protection, check your domains are listed as allowed and click Enable.

Protect the .htaccess file itself

Web servers normally refuse to show .htaccess files to visitors. To be sure, you can add:

<Files .htaccess>
  Require all denied
</Files>

Create a friendly URL

To let visitors use yourdomain.com/about for a page stored as about.php:

RewriteEngine On
RewriteRule ^about/?$ about.php [L]

WordPress manages its own rules in .htaccess. Don’t edit between the # BEGIN WordPress and # END WordPress lines; change WordPress web addresses under Settings › Permalinks instead.

For redirects, the Redirects tool in cPanel is easier and safer. If your site shows an error after an edit, undo your change or call us on (800) 245-6301.

Didn’t solve your problem?

Our team is here to help, any time, day or night.