How to prevent automatic redirection of 404 errors and “incorrect” URLs?

WordPress has a feature whereby it will automatically redirect your URLs if it percieves them to be written wrongly. Here is an example: I have a page called my-page

If I go to:

www.mysite.com/something/my-page/

it will immediately redirect me to

www.mysite.com/my-page/

as nothing exists at the first URL.

How can I turn this feature off, and instead just get a 404 if incorrect URL’s are typed in?

3

This worked for me:

remove_action('template_redirect', 'redirect_canonical');

Leave a Comment