Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com

How to Edit .htaccess File Print

  • 0

Learn to safely edit the .htaccess file for URL redirects, security, and performance improvements.

What is .htaccess?

The .htaccess file controls:
• URL redirects
• Access permissions
• Error pages
• Performance settings
• Security rules

Accessing .htaccess

1. Log into cPanel File Manager
2. Go to public_html folder
3. Click "Settings" and show hidden files
4. Find .htaccess file
5. Right-click and edit

Common .htaccess Rules

Force HTTPS:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect www to non-www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Block IP addresses:
order allow,deny
deny from 192.168.1.1
allow from all

Safety Tips

  • Always backup before editing
  • Test changes immediately
  • Keep original file copy
  • Use proper syntax
  • One rule per line

Was this answer helpful?

« Back

Powered by WHMCompleteSolution