Heree’s a code solution, not htaccess. This first checks if current query is for a category page, then checks category existence, and if category not exists but a tag with the same name, it redirects to the tag page.
add_action('parse_request', 'wpse_parse_request');
function wpse_parse_request( $r ){
if( isset($r->query_vars['category_name']) )
{
$cat = get_term_by('slug', $r->query_vars['category_name'], 'category');
if( !isset($cat->term_id) )
{
$tag = get_term_by('slug', $r->query_vars['category_name'], 'post_tag');
$link = get_term_link($tag);
if( !is_wp_error($link) )
{
wp_redirect($link);
exit;
}
}
}
}
Related Posts:
- 404 Error On Category and Tags Pages
- How to: 301 Redirect /category/ to /customname/
- How to? Redirect /category/sci-fi/ to /category/scifi/?
- Remove Parent Category from Child Category URL
- Changing permalink from /postname/ to category/postname/
- WordPress category page redirects in .htaccess not working
- Use blog as base for tags and categories
- Need help with major category and permalink re-organization
- WordPress Category url redirects to subdomain
- 404 error when i try to search by category or by tag
- WordPress category gives 404 after moving to a different domain
- Can’t custom taxonomies have same terms (slugs) as categories?
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- How to remove category from wordpress url?
- Use tag interface for hierarchical taxonomy?
- Multisite blog converting categories to subdomains
- Using URL parameters, list posts from category and custom taxonomy
- How to get the url to tag & category base set by the user?
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Create subdomains for tags and categories
- How to totally get rid of Category in my blog?
- Redirecting category link to first child post
- Root level category, tag, author and archive pages to work
- Showing all the posts in one page?
- Categories and Tags returning 404 on the sidebar when using ugly permalinks
- Archive pagination causing 404 with permalinks structure
- Is it possible to put tags and category information in the post as text?
- Script to duplicate categories as tags
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- display most popular tags of category?
- Redirect category to first available child post
- Can paginate_links() be customized for a specific category or tag?
- Why specific file directory fails to redirect but its parent folder succeeds?
- Any way to assign Post Categories and Tags to Links?
- Deny access to a path (give 403 or 404 response)
- Issue with htaccess redirection in WP Multisite
- Should the actual /category/ directory be 404? Is that normal WP behaviour
- How can I duplicate categories and tags?
- How to run select query of post with category and tags for API?
- Redirect category to url with /category
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- How to display categories which contains particular tag?
- WP didn’t redirect to canonical category URL
- “Categories” for six authors [closed]
- Same base for category and post
- How to “group” (categorize) the Pages together?
- Is There a Difference Between Taxonomies and Categories?
- Custom SQL Query: Get all posts with category id and a concated list of tags on each post
- Related Tags not in category
- scaleability of tags
- How do I add a tag slug to a category URL to filter posts?
- Show the amount of posts in a tag in a specific category has
- How can I redirect users on the new 404 page without plugin?
- Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)
- Custom page category taxonomy 404
- How to display post in custom file not in archive file?
- Conditional category & tag statement
- How to redirect non existent pages/posts in wordpress using htaccess
- How do I Redirect Tags from Old Joomla Site to New WordPress Site?
- Include either name or slug in the include parameter using wp_list_categories?
- List all posts of certain category which share some tags
- Category link redirect to custom template page instead of index.php?
- How can I filter posts by tag on the fly
- Retrieve post tags from from main wp_query
- Advanced permalinks structure
- Custom menu with categories and tags
- display specific category when website loads
- Automatically adding tags and categories into Post Excerpt for searching
- pagination 404 error, same slug home and categories
- OK to redirect the root WordPress category slug?
- Return all Tags and Categories in Separate List
- How to filter tags by category?
- Count how many posts have a specified tag AND category
- How to prevent tag “iframe” from being deleted from the heading description of rubric?
- When creating category, it creates automatically tag, or, when creating tag, it creates automatically category in same name
- How to fix 404 error in pagination in categories of woocommerce with common url base /shop/?
- Using heirarchial tags or Custom taxonomies
- Default URL for category dropdown select option
- Balance Tags to the_content Words Length
- How to echo Tags and Categories as plain text
- Categories and Tags Conflict after Woocommerce Installation
- How can I add metaboxs to Admin Bar?
- Exclude posts with certain tags in category archive
- Getting Post Tags From Certain Categories
- Changing post per page causing 404 for pagination. Need a redirect htaccess rule
- How to remove specific categories from tag archives?
- Page Type with Category Link
- A simple question regarding tags and categories
- Subpages return 404 server error
- How can I allow people to ‘subscribe’ to categories?
- How to add an empty entry to masonry?
- Own Custom Tags/Category page ( posts)
- Tracking multiple tags or categories
- Page redirecting to category (IE only)
- How to load jquery tag-it plugin into admin?
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- Query posts that have all the specified tags
- Moving Blog and Changing URL
- Post pages are redirecting to the 404 page in wordpress