Short answer: .htaccess is a configuration file in your website folder that Apache and LiteSpeed servers read on every request. It controls redirects, HTTPS, caching headers and access rules. One typo can cause a 500 error, so download a backup before every edit.
Where to find it
It lives in public_html and starts with a dot, so it's hidden by default. In cPanel's File Manager, open Settings and tick Show hidden files.
Useful examples
Force HTTPS
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Redirect one page
Redirect 301 /old-page/ https://yourdomain.com/new-page/
Block access to a sensitive file
<Files wp-config.php> Require all denied </Files>
Rules of thumb
- Back up first, then change one thing at a time.
- Test immediately after saving.
- Don't duplicate rules that a plugin already adds, which is a common cause of redirect loops. See fix too many redirects.
If you break the site
Restore your backup copy or remove the last change. A 500 error right after an edit almost always means a syntax error in .htaccess. See fix a 500 error.
Frequently asked questions
Does Nginx use .htaccess?
No. Nginx uses its own configuration files. LiteSpeed and Apache read .htaccess.
Can WordPress edit .htaccess?
Yes. WordPress and some plugins write rules between their own marker comments; leave those blocks intact.
Should I use .htaccess or cPanel for redirects?
cPanel's Redirects tool writes the same rules for you and is safer for simple redirects. See 301 vs 302 redirects.



