Title: Multisite permalink issue
Last modified: September 13, 2024

---

# Multisite permalink issue

 *  [Denis Žoljom](https://wordpress.org/support/users/dingo_d/)
 * (@dingo_d)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/multisite-permalink-issue-2/)
 * 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
 *     ```wp-block-code
       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
    -  This topic was modified 1 year, 9 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [lailagmelo](https://wordpress.org/support/users/lailagmelo/)
 * (@lailagmelo)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/multisite-permalink-issue-2/#post-18013233)
 * 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](https://wordpress.org/support/users/dingo_d/)
 * (@dingo_d)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/multisite-permalink-issue-2/#post-18013717)
 * 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)

The topic ‘Multisite permalink issue’ is closed to new replies.

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 2 replies
 * 2 participants
 * Last reply from: [Denis Žoljom](https://wordpress.org/support/users/dingo_d/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/multisite-permalink-issue-2/#post-18013717)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
