safe-redirect-manager icon indicating copy to clipboard operation
safe-redirect-manager copied to clipboard

Document or update multisite subdirectory site behavior

Open davidegreenwald opened this issue 4 years ago • 2 comments

For WordPress multisite use, this plugin runs into an edge case with subdirectory sites:

example.com/my-site

To add a redirect to this site, it needs to added to the subsite directly, and not from the primary example.com domain using the /my-site path, as we might expect. WordPress sends the request to the subsite before checking the primary site, where the rule can work.

If this subsite is archived, marked as spam, or marked as deleted (but not actually deleted), we can't cover it with any redirect rules - rules on the subsite no longer work, but rules on the main site don't work either, because WordPress still sees it as an available multisite and doesn't send the request to the primary domain for redirection.

If the subsite is physically deleted (say, after export to another domain), only then we can use SRM to create redirects on the main site to cover that path.

However, these rules are likely to conflict with Nginx/Apache rewrite rules which support subdirectory subsite usage of /wp-admin, and therefore no SRM rules can rewrite example.com/my-site/wp-admin because it's already been rewritten at the server level before it gets to WordPress. This is problematic for trying to fully redirect a subdirectory subsite to a new domain.

My suggestion would be some multisite documentation pointing out this case, clarifying that

  • active subdirectory subsites need their own rules
  • deleted subsites must be fully deleted for primary site rules to cover their paths, and to avoid grey-area state where no rules can be applied on the deactivated path
  • Higher-level server rules will prevent SRM from fully redirecting moved subdirectory subsites

It is more obvious to me that subsites with subdomains or mapped domains would get their own rules or need to be managed at a server level if those domains change, but that may also be worth a mention.

davidegreenwald avatar Jun 29 '20 20:06 davidegreenwald

@davidegreenwald thanks for the detailed report, we'll work to replicate/validate and see if there's a way to handle via code or if docs are the best route!

jeffpaul avatar Jun 29 '20 20:06 jeffpaul

@jeffpaul

If this subsite is archived, marked as spam, or marked as deleted (but not actually deleted), we can't cover it with any redirect rules - rules on the subsite no longer work, but rules on the main site don't work either, because WordPress still sees it as an available multisite and doesn't send the request to the primary domain for redirection.

I think it's fine and it's probably expected (plus, I don't see a way to get around this limitation) If needed to make sure the URL for the sub-dir need to fall back to the main site, the user/super-admin can always change the slug for the (deleted/archived/inactive) sub-site.

turtlepod avatar Aug 18 '22 21:08 turtlepod