Multisite permalink issue
-
I have a WP multisite on AWS running nginx based server. It has autoscaling enabled as well. For some reason, and for only some pages (mostly custom post types), after every deploy these CPT’s will give 404’s.
Then I need to manually go to the settings and go to permalinks and just resave the permalink structure to trigger rewrite rule flush.
Now, because we are deploying the site using codedeploy, I added a wpcli script that will do that for me
exec("~/bin/wp site list --json --field=url", $siteOuput, $return);
$siteList = json_decode($siteOuput[0], true);
foreach($siteList as $siteUrl) {
exec("~/bin/wp rewrite flush --url=$siteUrl", $permalinkOutput, $return);
}This seemingly works (we have logging where it says that the permalink flush was successful for sites). However this doesn’t seem to be the case. When I go to a CPT, it will throw 404 and I need to manually go to the settings and resave permalinks.
The rewrite rules are set in the database so this is super confusing. Also, flushing permalinks from wpcli obviously is not working, so is there a difference between web and cli context here?
I did try to trigger a call to a rest route that had the logic for flushing permalinks, but that also didn’t work (again here I suspected this won’t work from the rest API context).
Does anybody have idea what could be the issue and how to fix this? The main issue is that when autoscaling event happens, permalinks go kaput :S
- You must be logged in to reply to this topic.