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
- What’s the URL for a category archive?
- Rewrite rule page url with category
- How to create a custom url for a category [closed]
- how to use a different domain/subdomain for authors/catagories on single site?
- 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?
- Redirecting specific category posts to subdomain
- Will references to ugly links automatically redirect to their pretty url permalink?
- Categories’ hierarchy in URL
- 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: 301 Redirect /category/ to /customname/
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- 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
- How to link a PDF file to a category URL
- Use blog as base for tags and categories
- Category link redirect to custom template page instead of index.php?
- Redirect depending on category chosen
- How to Force WWW. in Domain With WordPress MU Domain Mapping Plugin?
- Custom url structure – pages under a custom post type
- Category URL Management
- 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
- Using custom structure prefix showing 404 for sub-categories
- Add custom categories and subcategories and posts as custom pages
- OK to redirect the root WordPress category slug?
- 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?
- i want to change URL of WordPress image or rewrite in runtime
- Can a Woocommerce product category URL contain “&”?
- How to remove parent category from child category url using wordpress rewrite rule?
- Category page 404s on mobile but not desktop?
- Category URL’s 404 after setting category base to ‘.’
- How to add a ‘News’ section to specific posts in WordPress
- 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
- Post url rewriting for posts with certain category
- Category and tag urls return 404 error
- Accessible Subcategory URL’s pages without using .php hack
- Any way to make Apache’s internal redirect work?
- Hide category name using mod_rewrite
- Hide category name in URL
- Paginations in Category Page Leads to Sample Pages
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- Create monthly archive for parent category
- 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
- Page redirecting to category (IE only)
- What approach should I take for this URL structure?
- How can I get rid of the the category suffix–NOT “prefix” (i.e. foo-1, foo-2, etc)
- WordPress 3.0 Multisite – Child sites and backends appearing blank
- Multiple Parent Category URLs
- Remove “?category=” in the URL wordpress ajax filter work for category
- Category Redirection Problem
- wordpress category rewrite rule with pagination
- Disable Category Link
- Link to a specifc category?
- How to redirect URL to a subdomain except one folder that needs to go somewhere else