What is .htaccess?

The .htaccess is an extremely powerful configuration file for your web server. With just a few lines of code, you can control your website's behavior – from automatic redirects to security measures.

Security Note: A single typo in this file can make your website unreachable ("Internal Server Error 500"). Therefore, always create a backup of the current file before making any changes.

Step 1: Finding the file in the File Manager

Files that start with a dot (like .htaccess) are treated as "hidden" by the system. Here is how to make them visible:

  1. Open the File Manager in cPanel.
  2. Click on Settings in the top right corner.
  3. Check the box "Show Hidden Files (dotfiles)".
  4. Click Save. The file will now appear in the public_html folder.

Practical Code Snippets

Simply copy these templates to the beginning of your .htaccess file:

1. Enforce HTTPS (SSL)
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
2. Block specific IP addresses

Ideal for manually excluding annoying attackers or bots:

Order Allow,Deny
Deny from 123.456.78.9
Allow from all
3. Protect directories without an index file

Prevents visitors from seeing a file list if no index.php is present:

Options -Indexes

Is your website showing an error after the change?
Don't panic! Simply delete the last change or upload your backup. If you have any questions, CURIAWEB Support is here to help!

Was this answer helpful? 1 Users Found This Useful (1 Votes)