How to stop WordPress from automatically doing a redirect?

Viewed 51

I have a site running on WordPress, and it will automatically redirects URLs it thinks are written incorrectly.

For example, if I go to a URL that doesn't exist. Like this one:

www.example.com/blah-blah/my-page-slug/

will redirect me to...

www.example.com/my-page-slug/

How can I stop this redirection? I want to generate a 404 error if the wrong URL is typed in, not redirect.

1 Answers

Place this in your theme's functions.php file.

remove_action('template_redirect', 'redirect_canonical');
Related