WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 2 months ago

#21573 new defect (bug)

NOBLOGREDIRECT interfering with 404 errors

Reported by: bungeshea Owned by:
Priority: normal Milestone: Awaiting Review
Component: Multisite Version: 3.4.1
Severity: normal Keywords: has-patch
Cc:

Description

When the NOBLOGREDIRECT constant is defined, 404 pages on the main site will not work and instead redirect to URL defined in NOBLOGREDIRECT. This is the cause of the maybe_redirect_404 action/function, which is not needed and should be removed.

Attachments (1)

21573.patch (748 bytes) - added by bungeshea 2 months ago.
Bail early in maybe_redirect_404 function on subdomain installs

Download all attachments as: .zip

Change History (14)

comment:3 bungeshea10 months ago

It seems that the main purpose of this function was intended for sub-directory installs; it should be modified to first check if a subdomain install is active and, if so, bail early.

comment:5 bungeshea2 months ago

@ottok I have applied the fix to my own site (@Fruumph actually posted that same link above), but I thought a fix should be implemented into core.

bungeshea2 months ago

Bail early in maybe_redirect_404 function on subdomain installs

comment:6 bungeshea2 months ago

  • Keywords has-patch added; needs-patch removed

comment:7 Frumph2 months ago

@bungeshea what about those people who would want to use the define on subdomain installs?

validsubdomain.domain.com/notvalidsuffix/ this needs to redirect to error page

notvalidsubdomain.domain.com/ this needs to be able to use the define

comment:8 bungeshea2 months ago

@Frumph I'm actually testing this code on my own site, and the behaviour is the same as when using the fix you posted about.

http://notvalidsubdomain.bungeshea.com/ redirects to location defined in NOBLOGREDIRECT (in this case, main site)

http://code-snippets.bungeshea.com/notvalidsuffix/ uses usual 404 error page

Last edited 2 months ago by bungeshea (previous) (diff)

comment:9 Frumph2 months ago

Your NOBLOGREDIRECT goes to the root page of the site is what you have it set for?

(re-read your comment)

Last edited 2 months ago by Frumph (previous) (diff)

comment:10 bungeshea2 months ago

So what would you suggest? An option in Network Settings, perhaps?

comment:11 Frumph2 months ago

No, my apologies, if the behavior you state is happening then i'm very cool with the end result.

the 404's going to the appropriate 404 page and the wrong subdomain going to the noblogredirect, that's expected behavior and how it should be. If your fix does that, then cool.

comment:12 bungeshea2 months ago

Yep, that's what it does alright. It just disables the 404-redirect-to-NOBLOGREGIRECT-functionality on the front-end only, and only for subdomain installs (subdirectory installs aren't affected). The wrong-blog-redirect functionality is handled elsewhere.

Last edited 2 months ago by bungeshea (previous) (diff)

comment:13 Frumph2 months ago

Cool yeah, expected behavior ftw.

Note: See TracTickets for help on using tickets.