WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


it will immediately redirect me to


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?

share|improve this question
If you watch what is happening (via HttpFox or WireShark or a similar packet sniffer), those pages redirect with a 301 Status-- Moved Permanently-- which is appropriate behavior. It helps search engines keep their databases up to date among other things, and the redirect helps users find pages. This may effect how WordPress handles things when you actually do move a page or change a permalink, so be careful. Anyway, your choice but I am not sure it is a good idea. – s_ha_dum Nov 8 '12 at 15:04
I know it's a good thing, I do understand that. However, I have a particular use case where I did not need that behaviour. I am developing a plugin which handles URL redirection and so I want to override that behavior. – Ash Nov 9 '12 at 11:28
Here is a more correct answer: link – Binod Dec 19 '14 at 10:54
up vote 3 down vote accepted

This worked for me:

remove_action('template_redirect', 'redirect_canonical');
share|improve this answer
Can you guide me for what it will do? what is canonical redirect? i am new to wordpress – Yatin Mistry Sep 25 '14 at 7:50
You just saved me a lot of headaches! thank you ! :-D – Jenski Feb 26 at 10:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.