is automatically redirecting to:


This is making it difficult to sort by multiple categories: http://localhost/?categoryname=apples+oranges and sorting by multiple custom taxonomies.

Any idea why it would be auto re-directing? I've disabled all plugins and it still does it.



WordPress uses the redirect_canonical function in order to ensure that URLs are properly following the current permalink structure: https://codex.wordpress.org/Function_Reference/redirect_canonical

The function is hooked to automatically run on the template_redirect filter. In order to remove it, you need to add the following snippet to your theme or plugin:

remove_filter( 'template_redirect', 'redirect_canonical' );

Keep in mind that this will allow a single page (in this case taxonomy index) to have multiple URLs, which is not good for SEO, because the following URLs will show the same content:

WordPress will also not handle http://localhost/?categoryname=apples+oranges automatically, since its base logic only works with a single taxonomy. The best way to approach this issue would be to use custom rewrite rules and to introduce a new rewrite/query tag, for example categories, instead of the default categoryname. This however, is a topic that cannot be explained quickly and requires some research first.

  • Thanks. That did work but you are correct it no longer redirects the /apples to /apples/ . However with Yoast SEO installed it seems the canonical tag on both pages are /apples/ so would that not resolve the SEO issue? – user3330820 Jan 10 '18 at 19:44
  • Please :) The issue is that search engines will find two pages with the same content and instead of a single page being ranked up, you would get the traffic split in two. As for the canonical tag by WordPress SEO, that should actually fix the issue. – Radoslav Georgiev Jan 10 '18 at 19:46

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.