Permalinks can break after migration due to missing .htaccess
rules, unflushed rewrite rules, or server-level issues like mod_rewrite being disabled.
WordPress permalinks not working after migration? You’re not alone. Whether you’ve just moved your site to a new domain or switched hosts, broken permalinks are one of the most frustrating post-migration issues. This guide walks you through how to fix it fast and restore clean, SEO-friendly URLs.
Why Permalinks Break After WordPress Migration
When you migrate a WordPress site, settings related to permalink structure often get corrupted or reset. This causes URLs to break, resulting in 404 errors, broken internal links, and tanked SEO performance. The good news? It’s fixable — and usually without any plugins.
1. Reset Permalinks via WordPress Settings
Go to Settings → Permalinks and simply hit “Save Changes” without editing anything. This flushes and rebuilds the rewrite rules. For most cases, this instantly fixes the issue.
2. Manually Flush Rewrite Rules (Code Method)
If your permalinks still don’t work, add this to your theme’s functions.php
temporarily:
flush_rewrite_rules();
This forces WordPress to rewrite permalink rules. Remember to remove this line after the first page load.
3. Check .htaccess File (Apache Servers)
For sites on Apache, a broken or missing .htaccess
file can block permalinks. Ensure this default WordPress block exists:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
4. Enable mod_rewrite Module
Still not fixed? Your Apache server might not have mod_rewrite
enabled. Contact your hosting support or enable it via terminal if self-hosted:
sudo a2enmod rewrite
sudo service apache2 restart
5. For NGINX Users: Check Rewrite Rules
If you’re on NGINX, permalinks won’t work with .htaccess. You’ll need to configure pretty permalinks manually inside your server block:
location / {
try_files $uri $uri/ /index.php?$args;
}
Update and reload NGINX using sudo service nginx reload
.
6. Database Migration Plugin Didn’t Rewrite URLs
Tools like Duplicator or All-in-One WP Migration sometimes skip URL rewrites. Use Better Search Replace to search and replace your old domain with the new one in the database.
7. Fix 404 Errors After Changing Permalink Structure
Changing permalink structure post-migration (e.g., from /?p=123 to /%postname%/) can break URLs. Always save permalinks after edits and redirect old URLs using Redirection.
8. Use .htaccess Redirects for Old URLs
If old URLs are indexed or linked elsewhere, redirect them using 301s in your .htaccess
:
Redirect 301 /old-post/ https://yoursite.com/new-post/
9. Clear All Caches
Always clear browser cache, WordPress caching plugins (like WP Rocket or W3 Total Cache), and CDN (like Cloudflare) after fixing permalink issues to reflect changes.
10. Restore SEO and Broken Links
Run a scan using Broken Link Checker and update internal links manually or via plugin. This helps recover from SEO loss due to the permalink structure breaking.
Conclusion
If your WordPress permalinks are not working after migration, don’t panic. Reset settings, check your server, flush rules, and rebuild your .htaccess or NGINX configs. You’ll have clean, crawlable, SEO-friendly URLs again in no time.
Still stuck? Contact me and I’ll help you sort it out personally.
If you’re also stuck on the login screen after migration, don’t miss our full guide on fixing the WordPress login redirect loop. And once your site’s stable again, check out our curated list of best WordPress plugins for business websites to help improve speed, security, SEO, and overall performance.