Opened 12 years ago
Last modified 3 months ago
#21573 new defect (bug)
NOBLOGREDIRECT interfering with 404 errors
Reported by: | bungeshea | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 3.4.1 |
Component: | Bootstrap/Load | Keywords: | needs-patch needs-unit-tests |
Focuses: | multisite | 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 (2)
Change History (28)
#2
@
12 years ago
Post about subject here: http://frumph.net/2010/06/05/wordpress-3-0-multisite-subdomain-installation-noblogredirect-behavior-fix/
Includes simple behavior fix.
#3
@
12 years 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.
#4
@
12 years ago
This bug seems to be a very long standing one. Here is a fix from 2010: http://frumph.net/2010/06/05/wordpress-3-0-multisite-subdomain-installation-noblogredirect-behavior-fix/
#5
@
12 years 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.
#7
@
12 years 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
#8
@
12 years 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
#9
@
12 years ago
Your NOBLOGREDIRECT goes to the root page of the site is what you have it set for?
(re-read your comment)
#11
@
12 years 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.
#12
@
12 years 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.
#15
@
11 years ago
- Milestone changed from Awaiting Review to Future Release
In a nutshell, from this ticket and #13689, with NOBLOGREDIRECT defined...
If I have /test/
setup as a subfolder site at mydomain.com
:
http://mydomain.com/test/
workshttp://mydomain.com/test/notapageurl/
, or any non existent URL on the subfolder site, gives me a/test/
404http://mydomain.com/anythingotherthantest/
, or any non existent URL on the main site, redirects to the URL specified in NOBLOGREDIRECT
If I have test.mydomain.com
setup as a subdomain site:
http://test.mydomain.com
workshttp://test.mydomain.com/notapage
, or any non existent URL on the subdomain site, gives me atest.mydomain.com
404http://notsubdomain.mydomain.com
redirects to the URL specified in NOBLOGREDIRECThttp://mydomain.com/notapage
, redirects to the URL specified in NOBLOGREDIRECT
It's that last item, where a 404 belonging to the primary site redirects to NOBLOGREDIRECT in a subdomain install, that is at the heart of the issue here. I would agree that this seems like unexpected behavior, though it appears like it has always been the behavior.
The current logic in maybe_redirect_404()
checks for is_main_site()
, but as stated earlier in this ticket and in the other, should probably look at is_subdomain_install()
as subdomains are much easier to determine intent with when trying to guess if dealing with a missing site or a missing page.
21573.2.diff is a slight variance from the patch uploaded by bungeshea and adds ! is_subdomain_install()
to the check before redirecting.
#20
@
10 years ago
This bug has just caught me out. Would love to see this patched in the next WP version.
#21
in reply to:
↑ description
@
10 years ago
Replying to bungeshea:
When the
NOBLOGREDIRECT
constant is defined, 404 pages on the main site will not work and instead redirect to URL defined inNOBLOGREDIRECT
. This is the cause of themaybe_redirect_404
action/function, which is not needed and should be removed.
Now, I removed the line of NOBLOGREDIRECT in my wp-config file and the error page on main site is working but the link must be together with www or else it turns out to this url http://www.example.my/wp-signup.php?new=example.com when i type any url without "www". I tried to fix this with .htaccess file to make it work. But, it would affect all the subdomain redirect to www as well. Example result: www.sub1.example.com. I don't want this happen to my sub domain. Any php code i can implement into wp-config to get this resolved?
#22
@
10 years ago
@Jornes83: Please don't post support requests here, instead use WordPress Developers or the Forums.
This ticket was mentioned in Slack in #core-multisite by alm. View the logs.
9 years ago
#24
@
9 years ago
Consider also the name of this constant being indicative of it's intention.
NOBLOGREDIRECT
Which translates to me as:
Redirect to $here when WordPress performed a blog lookup, and found no blog
In @jeremyfelt's testing above, he's correct that the 4th test in the subdomain group is, at the very least, unintended behavior, and should be addressed.
I wonder, though, what happens (and what should happen) in a few other cases:
- A subdirectory installation, but
http://noblog.bar.com
is visited - A subdirectory installation, but
http://noblog.bar.com/hello-world/
is visited - A subdirectory installation where the main site is also a subdomain like
http://central.wordcamp.org
buthttp://central.wordcamp.org/noblog/
is visited - A subdomain installation where the main site is also a subdomain like
http://central.wordcamp.org
buthttp://noblog.wordacmp.org/hello-world/
is visited - A subdomain installation where the main site is in a subdirectory like
http://foo.com/blog/
buthttp://support.foo.com
is visited
There's a bunch of goofy permutations that start to come down to server configuration, and WordPress can (should?) only make so many assumptions about this, and intelligently redirect to the most natural location when it doesn't find anything.
Related: ticket:13689:26