safe-redirect-manager
safe-redirect-manager copied to clipboard
Check non-active multisite directory against the main site redirects
Description of the Change
This PR contains fixes for this issue: https://github.com/10up/safe-redirect-manager/issues/212. Whenever the multisite subsite is not active, check the requested path against the saved redirect rules from the main website.
Verification Process
- Create a multisite installation with several sub-sites.
- Archive, deactivate or mark a site as spam
- Go to the main website and add a redirect rule for the subsite you've modified the status from step 2.
- Verify that the redirect is working.
Checklist:
- [x] I have read the CONTRIBUTING document.
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my change.
- [ ] All new and existing tests passed.
Applicable Issues
Changelog Entry
With this still in flux and the 1.10.1 release pending, I'm punting this to the 2.0.0 milestone to hopefully get resolved then.
the maybe_multisite()
function is called within maybe_redirect()
, registered to the template_redirect
hook.
Given the scenario described in #212 , the code attached to the template_redirect
hook will never be executed.
WordPress interrupts the hook sequence when it checks the blog status, returning the message This site has been archived or suspended.
I am refactoring this approach.
I'm so sorry for this super late review! Testing against latest commit, I'm still having the same issue as my previous test. Here are my steps:
- Create a sub directory multisite.
- Create a sub site with slug set to
two
. - Archive that site.
- Create a redirect rule in the main site from
/two/test/
to an arbitrary external site. - Try visiting
/two/test
, see the Archived site notice instead of the external site set in step above.
@ciprianimike can you please verify these steps on your end?
Screenshots



@dinhtungdu Did you, by any chance, have the plugin deactivated on the archived site?
I ran multiple tests on various different environments following the same steps as you, and @ciprianimike's fix seems always to work as expected. The only time it didn't work, was when I had the plugin inactive on the archived site. In that scenario, it makes sense that the redirect is never triggered, as we are still on the archived site and not on the main one. That's why deleting the site instead of archiving it restores the redirection: the second site no longer exists, and the main site's plugin, which is active, executes the code.
@Sidsector9 this is waiting on your review