Opened 3 years ago
Last modified 3 years ago
#54654 new defect (bug)
Can flush_rewrite_rules() be called automatically after changing the site URL?
Reported by: | pikamander2 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Rewrite Rules | Keywords: | |
Focuses: | Cc: |
Description
A common issue that users run into after changing the WordPress Address and/or Site Address (such as when migrating to a new domain) is that some of their links stop working correctly after a site change.
The most common fix/workaround is to go to the wp-admin > Settings > Permalinks page and click "Save" once or twice, which usually does the trick.
Examples of this problem and workaround can be found all over Google:
https://www.google.com/search?q=wordpress+links+not+working+after+migration
https://wordpress.stackexchange.com/questions/221108/wordpress-links-not-working-after-migration
https://wordpress.stackexchange.com/questions/14685/after-server-migration-only-the-homepage-works
https://stackoverflow.com/questions/42162570/wordpress-issue-after-migration-only-homepage-works
https://stackoverflow.com/questions/39514343/wordpress-migration-broken-links
I'm not sure if there's already a ticket for this anywhere, but surely there's some way to do this automatically? The view counters on the various Stack Exchange questions suggest that it has affected hundreds of thousands or even millions of users, so fixing it would be a fantastic QOL improvement, especially for non-technical users and users who don't notice the broken links until they start getting complaints.
Would it be possible to automatically flush_rewrite_rules() in the core function that handles the address change? I haven't looked into what happens when the permalink settings are resaved, but I would imagine that it does something similar there.
Change History (3)
#2
in reply to:
↑ description
@
3 years ago
- Component changed from General to Rewrite Rules
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Replying to pikamander2:
Would it be possible to automatically flush_rewrite_rules() in the core function that handles the address change?
As noted above, this does in fact already happen since WordPress 1.5.1. Some history here:
I'm not sure why this issue is still experienced, but here's a couple of references:
See update_home_siteurl().
See when it's called.