skip to Main Content

Currently running WordPress 4.9.5 using the Divi theme with Permalinks set to use Post name, I can enter a url (page title/name) that does not exist on the site and WordPress will deliver a page that has the “filename” part of the url somewhere in the title/name of the page it delivers but is different than the actual url.

For example, if you go to http://space.nss.org/renew/
Instead of getting a 404, WordPress delivers the page http://space.nss.org/renewable-energy-partnership/

What on Earth is WordPress thinking?

What can I do to identify the exact nature of the problem and fix it?

Note that this behavior is not universal as I can enter bad urls (like space.nss.org/armstrong/) and do get the expected error page.

Thanks in advance, Jim.

NOTE: The url referenced above (space.nss.org/renew/) has now been fixed so its original behavior is no longer exhibited.

2

Answers


  1. Chosen as BEST ANSWER

    With respect to my problem, it turns out that Wordpress is just trying to help by assuming that humans do not know how to type. When I type "space.nss.org/renew/" and Wordpress doesn't find an exact match, it looks for anything it can find containing the string "renew" and delivers what it considers to be the best match as a way of avoiding delivering a 404 page to the visitor.

    This feature can be turned off but there are consequences in that the 'redirect_canonical' is also responsible for resolving domain name issues (like www.domain.com vs domain.com). For reference, see https://codex.wordpress.org/Function_Reference/redirect_canonical

    Following are references on the subject I found once I knew what I was looking for.
    [https://wordpress.stackexchange.com/questions/3326/301-redirect-instead-of-404-when-url-is-a-prefix-of-a-post-or-page-name]

    2 [https://serverfault.com/questions/776310/how-to-disable-the-automatic-redirection-in-wordpress-htaccess-file]

    3 [http://biostall.com/prevent-wordpress-redirecting-to-nearest-matching-url/]


  2. Looking at the network log it appears there is a 301 redirect placed on /renew to go to /renewable-energy-partnership

    As a solution you could remove the redirect so that it goes to the 404 page instead.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search