We are overriding 404.php to show database generated content like this:


(if the url is /products/../ the 404 process is converted into a page).

Problem is that we have some media files that have permalink similar to the last part of our database generated content urls.

For example /x1/ which causes /products/x1/ to be redirected to /x1/ instead of showing the database generated content for /products/x1/.

Same thing with a post url like this /x2-specs/. It causes /products/x2/ to be redirected to the post instead of showing the database generated content for /products/x2/.

How do we disable the redirect of all urls that contain /products/?


  • What have you looked into and tried so far? Oct 3, 2016 at 18:56
  • I was wondering if there is a redirect filter or something than handles the automatic redirections?
    – Louisa
    Oct 3, 2016 at 19:11
  • Can you explain how you are "overriding" the 404s? Oct 3, 2016 at 19:12
  • If url contains /products/ { drop 404 message and show database generated content instead} else { normal 404 page }
    – Louisa
    Oct 3, 2016 at 19:14
  • 1
    asking about fixing your code without showing it is mostly pointless, even if it is not needed for the question, at its current state it is hard to uderstand what is it that you are actually trying to do. Oct 4, 2016 at 6:38

1 Answer 1


This fixes the problem:

remove_action('template_redirect', 'redirect_canonical');
  • this will creat duplicate content all over your site Oct 4, 2016 at 6:36
  • How come it will create duplicate content?
    – Louisa
    Oct 4, 2016 at 23:01
  • hmmm, I probably was somewhat wrong with the exact term, but in the end you have a local problem and your solution is global - disable basic wordpress functionality that ensure that all content have only one url. maybe with other things in place like canonical url this will not hurt SEO but th idea of just globaly disable a core wordpress feature just stinks Oct 4, 2016 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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