Reputation: 43
I have a problem with a Wordpress permalink.
These are my steps to show the problem:
1) in admin > pages: I create new page call "GoodMorning" and I have slug "goodmorning", on frontend, I run ://my_domain/goodmorning will show the content of this page
2) Now, I run ://my_domain/find-me/goodmorning it will auto redirect to ://my_domain/goodmorning
/find-me/ : this is any name and this text does not exist on wordpress slug, category, page, post, ....
Please let me know why. I want it to show a 404 page when I run ://my_domain/find-me/goodmorning.
Thanks All.
Upvotes: 0
Views: 37
Reputation: 4611
Adding this (to functions.php
) should stop that redirect.
remove_action('template_redirect', 'redirect_canonical');
If you look at the documentation for redirect_canonical
here:
Will also attempt to find the correct link when a user enters a URL that does not exist based on exact WordPress query. Will instead try to parse the URL or query in an attempt to figure the correct page to go to.
I assume that's what you're trying to prevent based on your question.
If you need the other functionality of redirect_canonical
you can just cancel the redirect by returning false
to this filter, like so:
add_filter('redirect_canonical', '__return_false');
You need to flush your permalinks configuration afterwards:
Upvotes: 1