• 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Nginx cache is pretty persistent, are you flushing the cache before and after changing the permalinks? Or disable it until you can make sure the permalinks are working as intended.

    Thread Starter Denis ?oljom

    (@dingo_d)

    We don’t have nginx cache, but varnish and cloudflare, but those get purged. We are also clearing transients and cache flush because of redis, just to be safe. Then the last thing that is done is permalink flush.

    The strange thing is that I’ve ssh’d to the static instance we have and ran the command manually for the URL and that worked.

    I’m not sure where the problem could be tbh.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.