I’ve fixed it with the following code:
/**
* Redirect '/tag/[0-9]/{tag_name}/' to the correct tag.
*/
add_filter('request', function($qv) {
if (array_key_exists('category_name', $qv) && preg_match('/(tag\/)([0-9]*)/', $qv['category_name'])) {
$qv = [
'tag' => $qv['name']
];
}
return $qv;
});
I’m not sure if this is the right way, but it works!
Related Posts:
- add_rewrite_rule: $matches var not replaced by captured value
- How to change default page slug?
- How do I add a add_rewrite_rule without it redirecting?
- Custom rewrite rule
- Redirect empty search to another page
- Broken page redirect
- Migration from old CMS to WordPress 301 redirection rules?
- Change the “page” slug in pagination
- Understanding add_rewrite_rule
- generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?
- Custom permalinks with NextGEN Gallery
- Preventing index.php?category_name=something from redirecting
- Rewrite Rules for Multiple (more than 2) Taxonomies
- add_rewrite_rule not loading correct page nor getting variables
- SEO Friendly URLs for my plugin categories
- WordPress URL rewrite regex
- Blog installed in subdirectory but need to create pages in root. How to use permalinks?
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- Custom rewrite rule for backend/admin?
- How to have multiple rewrite endpoints in the same URL?
- add_rewrite_rule is not taking effect in WordPress? .htaccess file doesn’t update
- Why is WP creating both “/?tag=” and “/tag/” URLS for same content?
- Regionalised Content
- Add specific word to default page permalink
- URL Rewrite doesn’t work for nested pages
- Plugin action rewrite rule – non_wp_rules
- Map alt domain to specific section of website w/o MU
- Is it possible to generate an alternate structure for multi-tag urls?
- Rewrite rule to load images from production does nothing
- Custom query_vars and parse_request on wp-admin
- Have two different URLs show the homepage
- Double domain name in category URL-s
- My WP_options db rewrite_rules Does Not Work
- Rewrite Preview URL to include index.php
- How to disable URL rewriting for specific URLs?
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- WP is ignoring .htaccess rewritten URL
- Rewrite ugly URL to clean URL
- Rewrite wp-login.php URLS to static pages?
- Rewrite custom post type URL parameters
- How to remove wordpress directory slash
- Changed pagination URLS to use p= instead of paged=
- Change pagination url format
- Rewrite: WordPress URL rewrite on Search
- WPML language switcher for custom rewrite rules
- How to write Rewrite rule for same path using Rewrite API?
- Multiple query vars sorting combination and url rewrite
- URL rewriting with custom user meta “/%shop_name%/gallery/%gallery%”
- WordPress keeps writing rewrite rules to .htaccess
- URL Rewrite and add_query_var not working
- How to redirect a link to a new link?
- 301 Redirect all posts urls from .html to / (without .html)
- How to add custom rewrite rules and point to specific templates
- Custom rewrite after the default term link URL
- How can I reduce the number of rewrite rules?
- Capturing /page-name/[0-99999] in both template and number
- custom wordpress rewrite
- Keep requested/entered url with add_rewrite_rule
- Get wordpress installation folder
- Name page template properly
- Rewrite Rule for homepage not working correctly
- One off rewrite for single post-type slug (show normal page with same URL instead)
- Adding Rewrite URL for Base + Children Separately
- WP redirect rule doesn’t work
- URL rewrite in theme doesn’t seem to be working
- Rewrite rule that wp-login.php?action=register is left alone
- WordPress 3.1.2 Network Enabled non-www to www
- Trying to add array of paths to post permalink
- How to rewrite URL back to default custom URL if no destination found
- add_rewrite_rule() issue with parent/child/child page
- Dynamic URL with rewrite rule not working
- How can I add a vanity URL for admin-ajax.php Calls?
- Rewrite rule can’t get the ID from rewrited
- Pretty URL via Rewrite
- URL rewrite problem in WordPress plugin
- WordPress numeric (yearly) page names / disable yearly archives
- Usw add_rewrite_rule to display frontpage on specific page
- “SAVE PERMALINKS” does more than FLUSH_REWRITE_RULES?
- Rewriting URL with child pages
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Pagination appearing twice in URL after rewrite
- Need help with custom rewrite rule
- Rewrite rules goes away
- WordPress doesn’t remember my custom rewrite rule
- Custom urls in WordPress involving page slugs
- how to change some of the rules in the database
- .htaccess RewriteBase equivalent for WordPress – Passing a URL as a variable without getting a 404
- Rewriting URLs with query strings and preserving them
- get_permalink is getting old rewrite rule
- WordPress permalink still not working (error or not understood?)
- Rewrite URL based on form input
- Custom Rewrite for Profiles
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- Custom Rewrite Problem
- WordPress post-type create url rewriting
- help with rewrite_tag and rewrite_rule for custom page GET variables [duplicate]
- Wrong rewrite rules
- Rewrite and replace url wp-admin/edit.php and wp-admin/post-new.php