• Resolved ciceronepavaloi

    (@ciceronepavaloi)


    Hi, first let me say that your plugin is a very satisfactory one, deals with about anything I expected it to do, thanks for developing it.

    There is a misbehaviour when one tries to access a non existing url that should go to the 404 page, specifically a simple one level path url.

    Example:
    Without the plugin active, both example.com/level1path and example.com/level1path/level2path goes to the 404 page (as it should, because there is no level1path or level2path page or anything).
    With the plugin active, example.com/level1path redirects to the homepage… example.com/level1path/level2path is ok, goes to 404.

    I need to catch all the wrong urls using the 404 error. Is there something I can try to fidle with? Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Hey @ciceronepavaloi thanks for the kind words!

    I just quickly tried to replicate this issue using WP v6.02, a default theme, and no other plugins active, but both urls return a 404 page as expected. It’s possible Disable Blog is the source, but this makes me think it’s more likely a conflict with another plugin or theme.

    Are you able to perform a similar test on your site? I’ll need more information to try and replicate it before I can offer any fix that might be needed to the Disable Blog plugin.

    All redirects for public pages are done via the redirect_public_pages function in /includes/class-disable-blog-public.php (see the git repo)

    Disable Blog only runs a redirect if WordPress core returns one of a few specific conditionals, which further leads me to think in your situation something else is going on. WordPress core is not recognizing the first url as a 404 on your site, before Disable Blog even runs the redirect, and instead your site is considering that url as one of the following: a post, a tag/category archive, the blog page, a date archive, or an author archive.

    You can completely remove the redirects using the dwpb_redirect_front_end filter and passing false – placing the following line in your functions.php file or a custom plugin file will do the trick:

    add_filter( 'dwpb_redirect_front_end', '__return_false' );

    If you want to be more targeted, you can use the dwpb_front_end_redirect_url filter which passes the $redirect_url string.

    Let me know how best I can help from here.

    Thread Starter ciceronepavaloi

    (@ciceronepavaloi)

    Thank you for the quick response.

    I’ll try first with no other plugins and a default theme. Maybe it has something to do with the fact that i have wordpress installed in a subfolder (like example.com/website but it is served from root example.com). If that is not the culprit, I’ll check if one of the plugins or the theme is conflicting.

    For now, the sugested filters may be the quickfix for me – the site has no blog posts anyway.

    I’ll be back with my findings, thanks.

    Thread Starter ciceronepavaloi

    (@ciceronepavaloi)

    Hi again.

    I tried without any other plugins and with a default theme and the described misbehaviour persisted. So I fresh installed wordpress on another domain, and no matter if is in the root or run from a subfolder the misbehaviour did NOT appear…

    That got me thinking of what anything else I do after a new wp install… Well, I set the permalinks to custom /%category%/%postname%/ ??

    That seeams to be the culprit. If I set other stock permalinks or anything else custom like /%author%/%postname%/ the redirections work as expected.

    I did notice that with the plugin active one can no longer select /%category%/ to be used in permalinks, but I had it like this before installing the plugin. So maybe this is something you could check… I’m not sure if other custom post types that use the default category taxonomy or some custom ones can be affected, but I belive not many web developers test for 404s, so it may not be too important.

    Thanks for the time you spent looking into this and for the effort you put into developing free useful plugins.

    Cheers.

    Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Hey again,

    Sorry it’s taken me so long to get back to this, but I took some time to review this issue further. As far as I can tell, you’ll likely want to make some changes to your permalink settings.

    I was able to confirm that the %category% permalink option will result in redirecting any url in the /level1path/ format in your above example to the homepage. That is not what you would expect, but only happens with the %category% structure in place and the plugin active. Remove the %category% base and the urls will go back to the expected result: 404 pages.

    For context: When the plugin is active it will disables the ‘post’ content type, which also disables functionality related to the built-in categories and tags taxonomies – by default only used by the ‘post’ type. With no categories, the plugin will remove the category as an option for the permalink structure.

    So, typically if you’re disabling the blog, you won’t have categories or tags because you don’t have posts, and you also won’t use non-existent category or tags in your permalink structure.

    (Sidenote: If you have a custom post type that is using the built-in ‘category’ taxonomy, then these features will remain, but most sites do not have custom post types acting in this way)

    I’m going to close this topic, because after digging into this further I don’t think anything in the plugin needs to change necessarily. However, please reach out if you have additional issues or questions – feel free to re-open this topic or start a new one, as appropriate.

    Thanks,
    Joshua

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Some redirections in frontend misbehave’ is closed to new replies.