Site icon Hip-Hop Website Design and Development

Force custom taxonomy query to redirect to a pretty link?

We have custom taxonomy that is ‘news-categories’ with a term such as ‘news’ and ‘press’.

I set up a rewrite rule using wp_rewrite so that visiting ‘domain.com/news’ will display an archives page for the term ‘news’ of that custom taxonomy.

$rules['news/page/?([0-9]{1,})/?$'] = 'index.php?news-categories=news&paged=$matches[1]';

$wp_rewrite->rules = $rules + $wp_rewrite->rules;

It works great, except SEO plugins are pulling the canonical link as ‘domain.com/?news-categories=news’ and when I visit ‘domain.com/?news-categories=news’ that page also exists flat out instead of going to ‘domain.com/news’.

So basically I have two duplicate pages to some degree, any ideas on how to resolve it so that visiting ‘domain.com/?news-categories=news’ just redirects properly to ‘domain.com/news’ or doesn’t exist at all?