Default WordPress .htaccess Rules Explained
WordPress relies on a special set of rewrite rules inside the .htaccess file to enable
permalinks, route URLs correctly, and load your content through index.php.
If this file becomes corrupted, your site may display 404 errors or fail to load pages.
Below is the default WordPress .htaccess block:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
What These Rewrite Rules Do
- RewriteEngine On — enables Apache’s rewrite engine.
- RewriteBase / — sets the root folder as the rewrite base.
- RewriteCond %{REQUEST_FILENAME} !-f — if the file does NOT exist…
- RewriteCond %{REQUEST_FILENAME} !-d — and the directory does NOT exist…
- RewriteRule . /index.php — route the request through WordPress.
When You Should Restore the Default .htaccess
Restore your .htaccess if you experience:
- 404 errors on all pages or posts
- Permalinks not working after migration
- Corrupted rewrite rules caused by plugins
- Missing .htaccess file
How to Restore the Default .htaccess File
- Log in to cPanel.
- Open File Manager.
- Navigate to
public_htmlor your WordPress folder. - Right-click the .htaccess file → Edit.
- Replace its contents with the default WordPress block.
- Click Save.
Regenerating .htaccess Inside WordPress Admin
- Log in to wp-admin.
- Go to Settings → Permalinks.
- Click Save Changes (no need to modify anything).
WordPress will recreate a correct and complete .htaccess file automatically.
Notes & Tips
- If WordPress is installed in a subfolder, adjust
RewriteBaseaccordingly. - Caching or security plugins may append extra rules — this is normal.
- When using WooCommerce or custom post types, always refresh permalinks after changes.
Boost Your WordPress Performance
Check out our fully optimised WordPress hosting plans with automatic updates, security tools and speed enhancements.
Explore WordPress Hosting & Toolkit →