Using .htaccess to Control Site Access Print


The .htaccess file is a powerful configuration file used on Apache-based servers (like Aviumshost). You can use it to control access, apply redirects, and enhance security.

Examples:

1. Block an IP Address:

Order Deny,Allow
Deny from 123.456.789.0

2. Password Protect a Directory:

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/youruser/.htpasswd
Require valid-user

3. Disable Directory Listing:

Options -Indexes

To edit .htaccess:

  1. Open File Manager in cPanel.
  2. Make sure hidden files are visible.
  3. Edit the .htaccess file in your domain’s root folder.

Warning: Always back up your .htaccess file before editing. A typo can cause site errors.


Was this answer helpful?

Related Articles

How to Password-Protect a Directory in cPanel If you need to restrict access to a specific folder on your website (such as an admin area or... Enabling Two-Factor Authentication on Your Aviumshost Account Protect your account from unauthorized access by enabling Two-Factor Authentication (2FA). This... What is ModSecurity and How to Use It ModSecurity is a powerful web application firewall (WAF) built into your Aviumshost hosting. It... How to Use IP Blocker to Restrict Access Want to stop unwanted visitors or bots from accessing your website? Use the IP Blocker tool in... How to Set Up SSH Access Securely SSH (Secure Shell) allows advanced users to access their hosting server via a command-line...
« Back