I am sure I am going to sound the newb here, but this is something I have not noticed up till now with all the work I have ever done with WordPress.
Today I noticed that if I even if I only enter a portion of a post's name in the URL query, WordPress will try to find and show a matching post. For example, if I go to:
example.com/about
It will take me to:
example.com/about-us (which is the correct post name).
Another example, is if I go to:
example.com/priv
WordPress takes me:
example.com/privacy-policy
Did WordPress always do this? If so, then I never noticed (and will sound dumb asking this). I assumed it would give me 404 if the post name in the query was not found.
Cheers
Related
I discovered a strange behaviour of WordPress in the usage of permalinks. On my local machine set the permalinkstructure to:
/%test%/%year%/%monthnum%/%day%/%postname%/
The first part, "test" is a custom taxonomy.
This results in the following working linkstructure.
http://localhost:8080/reisbowl/2021/06/22/c/
But also, when use the url,which does not exist, the link is working and showing me the correct post "c".
http://localhost:8080/hamburger/2021/06/22/c/
How is that? Is WordPress ignoring the custom taxonomy segment in the permalink or everything but the title?
The question poped up because i have to rename the "reisbowl" tag (just an example) to something else and secure the redirection to the new url. But it seems that this is not any issue.
But why? I just want to understand that.
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.
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/]
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.
The title is pretty self explanatory, but I'm trying to figure out why WordPress allows this or if it's a setting in .htaccess perhaps, but here's the example:
I have a page, lets say a "Contact" page with the slug of "contact-us".
I go to http://example.com/contact-us/ -- everything works normally
I go to http://example.com/contact-us/contact-us/contact-us/contact-us/contact-us/contact-us (I could do this a million times) and it does NOT trigger a 404 error!
Why is this? If I enter a random string of numbers, it instantly triggers 404.php, but just repeating the page-slug does not trigger a 404.
I would like the page-slug to not be able to be repeated over and over again and trigger a 404 if it even gets repeated once.
Has anyone else experienced this issue? Is it possibly a canonical link issue or a "nofollow". I just don't understand why WordPress is not seeing this as 404 material.
Thanks in advance for any replies, suggestions, and help.
I have found a way to solve my own problem. Today I noticed that I was running two WordPress builds on the same server but one went to 404 while the other would just go back to the page. Now I knew it was a theme specific issue.
The answer is really simple actually, it was a permalink issue. In order for me to get the behavior I was looking for, I had to select "Post Name" as my permalink settings.
I previously had a custom string of options for a different style display using "Custom Structure", which I'm assuming had the "failsafe" in it.
I'm willing to switch out the extra permalink styling options in favor of the 404.
Although, those that opt to use a custom permalink structure should see if this happens to you.
not sure how to get around this one. Anyways so I am working on a WP blog http://athenasweb.com
However every post I make the url is not athenasweb, but instead 1and1's default URL before the domain name was switched over:
http://s433108212.onlinehome.us/
This is really annoying especially when linking to new posts, anyway to change this in wordpress?
Example this: http://s433108212.onlinehome.us/aspectarian-nov-2nd-nov-8th-2012/
Should be http://athenasweb.com/aspectarian-nov-2nd-nov-8th-2012/
Go to general settings and make sure the wordpress address and site address match what you want it to be.
I am not a wordpress guy and a client needs me to modify some pages. Someone else has created the entire site in wordpress.
I am having trouble with a query string that contains variables.
wordpresssite.com/pages-using-template/?variable=something
This causes the page to get thrown to the default 404 for the site..
Any suggestions on which file i need to fix this in and how to do it?
Thanks
wordpresssite.com/pages-using-template/?variable=something
That's giving you a 404 error, probably because you're trying to add the query string variable to the home page of the site. There's no "file" that fixes this - WordPress is dynamic. the .htaccess rules handle the URL rewrites ("pretty permalinks")
So I guess you need to give more information on what it is you're trying to do. There's not going to really be a way to "fix" the URL without breaking the rest of the site (it's possible, but I'm betting that whatever it is you're trying to do requires a much simpler solution).
What query string are you trying to add in? For what reason?
For example, I recently did a WordPress site from someone who needed a directory on one page of the site, that had a custom search from in it. I created a function that would $_GET the URL of the page and add the search query to it, and then return the end user to the page with the results there.
You also have to be careful about the $_GET in your functions - you want to be sure they're protected against injection attacks by using $wpdb->escape($_GET['xxx']).