Permalink Change Redirect Builder
Build Apache or Nginx redirect rules for a WooCommerce product URL structure change, like dropping the category from the URL.
Your details
Redirect rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^product-category/([^/]+)/([^/]+)/?$ /$1 [R=301,L]
</IfModule>Change the permalink structure first at **WooCommerce → Settings → Products → General → Product data → Permalink settings**, then re-save your permalinks at **Settings → Permalinks**. These rules catch anyone using the old links (bookmarks, backlinks, search results) after the switch.
$1/$2 capture groups depend on your exact old pattern. Test one real old URL before relying on this in production.
Why this needs its own redirects
WooCommerce builds a product's URL from a permalink structure you set at WooCommerce → Settings → Products → General → Product data → Permalink settings, options like the shop base, or including the product category in the path. Changing that setting changes every product's URL at once. WordPress doesn't create redirects from the old structure to the new one automatically, so anyone with an old link (bookmarks, backlinks, search results) hits a 404 until you add one.
This tool builds a capture-group rule for the two most common changes (removing the category from the URL, or removing the shop base) or a custom pattern, for either Apache (.htaccess) or Nginx.
Making the change
- 01
Change the permalink setting
WooCommerce → Settings → Products → General, update Permalink settings, and save.
- 02
Re-save permalinks
Go to Settings → Permalinks and click Save Changes, even without changing anything, to flush WordPress's rewrite rules.
- 03
Add the redirect rule
Paste the generated rule into your .htaccess (Apache) above the WordPress block, or into your Nginx server block.
- 04
Test a real old URL
Open a product page using its old URL and confirm it redirects to the new one.
Pitfalls
- On Apache, paste the rule above the
# BEGIN WordPressblock, or WordPress's own rules may catch the request first. - Test the capture groups against a real product URL: a pattern that's slightly off will redirect to the wrong page instead of 404ing, which is harder to notice.
- This only handles the URL structure. If you also changed category or product slugs individually, use the Nginx redirect generator or the regex tester for those one-off cases.
Questions people ask
Where do I change the product permalink setting?
WooCommerce → Settings → Products → General, under Permalink settings at the bottom of the page.
Do I need to redirect category and tag pages too?
Only if their URLs also changed. Product category and tag archive URLs use WordPress's normal permalink settings, separate from the product base.
Will this affect my SEO rankings?
A correctly set up 301 redirect preserves most of a page's search ranking value. Missing redirects (plain 404s) are what actually costs rankings and traffic.
Nginx or Apache, which do I use?
Check with your host if you're not sure. Most managed WordPress hosts use Nginx or a mix of both; shared hosting more often uses Apache with .htaccess.
Related tools
Last reviewed 30 September 2026.
Sources: WooCommerce docs: Change a product's URL · Apache docs: mod_rewrite · Nginx docs: ngx_http_rewrite_module (return, rewrite)
