
The .htaccess file is a small but powerful configuration file used by Apache and LiteSpeed web servers (which most shared hosts use). WordPress uses it for pretty permalinks, and you can also use it for redirects, security rules, and caching. Here is how to find, edit, or create it.
Important: a single typo in .htaccess can take your site down with a 500 error. Always download a backup copy before editing. If your host uses Nginx, there is no .htaccess file; server rules are managed by your host instead.
The Default WordPress .htaccess Code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Add your own rules above # BEGIN WordPress, never between the BEGIN and END lines, because WordPress may overwrite that section.
The Easiest Fix: Let WordPress Recreate It
If your .htaccess is missing or broken and your permalinks show 404 errors, go to Settings > Permalinks and click Save Changes without changing anything. WordPress regenerates its default rules automatically (if the server allows it).
How to Find .htaccess in cPanel File Manager
- Log in to cPanel and open File Manager.
- Click Settings (top right) and tick Show Hidden Files (dotfiles). Files starting with a dot are hidden by default.
- Open your WordPress folder, usually
public_html. - Right-click
.htaccessand choose Download to back it up, then Edit to change it. - Save your changes and test your site.

Your host uses a different dashboard? Most have a similar File Manager, or you can use FTP with FileZilla (enable showing hidden files there too). See also how to use cPanel File Manager.
How to Create a .htaccess File
- In File Manager, open your WordPress folder.
- Click + File (New File), name it exactly
.htaccess(with the dot and no extension), and create it. - Edit it, paste the default WordPress code above, and save.
Edit .htaccess From WordPress
- Rank Math: go to Rank Math SEO > General Settings > Edit .htaccess (enable Advanced Mode if you do not see it).
- Plugin: Htaccess File Editor lets you edit the file safely and keeps backups.
Frequently Asked Questions
Where is the .htaccess file in WordPress?
In your WordPress root folder, usually public_html, next to wp-config.php. It is hidden by default because its name starts with a dot.
What if my site breaks after editing .htaccess?
Restore your backup copy through File Manager or FTP, or rename the file and resave your permalinks to regenerate it.
Does every WordPress site have a .htaccess file?
Only sites on Apache or LiteSpeed servers. Nginx servers do not use it.
Leave a Reply