Filter category_link
so WordPress creates slashed URLs for categories, and redirect_canonical
so it accepts those URLs:
add_filter( 'category_link', 'wpse_71666_trailingslash_cat_url' );
add_filter( 'redirect_canonical', 'wpse_71666_trailingslash_cat_url', 20, 2 );
function wpse_71666_trailingslash_cat_url( $url, $request="" )
{
if ( 'category_link' === current_filter() )
return rtrim( $url, "https://wordpress.stackexchange.com/" ) . "https://wordpress.stackexchange.com/";
if ( "$url/" === $request and is_category() )
return $request;
return $url;
}
Related Posts:
- Posts URL structure like site.com/category/the-post-title
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Multiple post categories – single permalink
- Preventing index.php?category_name=something from redirecting
- Rewrite category wordpress
- How to? Redirect /category/sci-fi/ to /category/scifi/?
- Exclude subcategories from the url
- Add “page-a” slug to category link if user visit category link from “page-a”
- Rewrite a category
- How do I get rid of “category” from my URL structure?
- Remove subcategory and category with some rules from permalink
- Custom category URL rewriting
- How do I add a tag slug to a category URL to filter posts?
- Redirect Problems with Archive Page and GET variables
- Include specific category in URL automatically
- A different permalink structure for different categories
- WordPress Category url redirects to subdomain
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Modify / Rewrite single template url structure
- How to get permalinks with category base working with sub-categories
- How to remove the term “category” from category pagination?
- Best Way to Redirect Category to Page and Hide Category
- Filtering categories in the permalink structure
- Rewrite rule page url with category
- Multisite blog converting categories to subdomains
- Using URL parameters, list posts from category and custom taxonomy
- Custom post types with their own permalink structure
- Optimal way to redirect home page to category archive?
- Category and tag with same name
- How to create non-unique sub-category slugs?
- Rewrite category slug
- WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)
- Changing the category permalink structure
- How to display only the parent category in the permalink
- Redirecting category link to first child post
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- Page with the same name of a category
- Plural Category Base Slug On Category Archive Page
- Alias ‘wp-content’ directory to something shorter (framework?)
- Custom Category/Subcategory structure
- One WP install, I need to map a custom domain name to each category
- How to show in search results posts with a particular tag in a particular category?
- “Reversable” and “Re-useable” Subcategories (or other taxonomic structure)
- Categories not working – 404 Not found error
- How to set up Author archives with sub category URL
- Viewing category pages without the word ‘category’ in URL
- add_rewrite_rule fro html to another url not working
- Redirect category to url with /category
- WordPress category page redirects in .htaccess not working
- Why do my categories redirect?
- How to change category and year archive permalinks/rewrite rules?
- Wildcard forward all posts and pages with few exceptions
- Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts
- WP didn’t redirect to canonical category URL
- Add /category/ to an author archive page
- Permalinks: display just one kind of wp category in the posts url
- How to redirect large amount of URLs?
- Multiple URL’s based on category for one post
- WordPress URL Rewrite for dynamic and customized URL
- Flat category URLs but retaining hierarchy?
- menu using category and tags
- redirecting from a general category page to another specific one
- Have multiple category queries from the URL been fixed yet?
- How do I Redirect a WordPress Page?
- Is WordPress API visible from PHP file called in htaccess
- Nicer URL for viewing category of posts?
- WordPress link to post links to category (loop)
- Getting back a permalink from custom url
- Custom Post Type Category URL
- What Must to Display the “mysite.com/category” URL?
- How to display post in custom file not in archive file?
- How to link a PDF file to a category URL
- Need help with major category and permalink re-organization
- Global navigation in multisite: problem with categories
- WooCommerce Product category can be shown with multiple related URLs
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- remove url from categories
- How to remove category name for only one category?
- How to set the same base url for two different taxonomies?
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- Is this process OK to replace URL structure?
- Can a Woocommerce product category URL contain “&”?
- Category pages redirecting to tab on Posts page grid
- How do I rewrite a single category link to point to a custom page?
- Remove “category” from permalink with add_rewrite_rule
- Change the full slug for a specific category?
- Default URL for category dropdown select option
- Category and tag urls return 404 error
- Accessible Subcategory URL’s pages without using .php hack
- Hide category name using mod_rewrite
- Hide category name in URL
- Paginations in Category Page Leads to Sample Pages
- hierarchical taxonomy in permalinks? using same slug
- How to create short urls for sharing and downloadable content?
- htaccess redirect for all categories converted to tags now showing 404
- Customize category URL
- WordPress 3.0 Multisite – Child sites and backends appearing blank
- Remove “?category=” in the URL wordpress ajax filter work for category
- Category Redirection Problem
- wordpress category rewrite rule with pagination