![](https://www.businessbloomer.com/wp-content/uploads/2024/10/url.jpg)
In a recent Business Bloomer Club Slack thread, a WooCommerce user asked if it’s possible to remove the default “product” keyword from product URLs, aiming to simplify the URL structure from https://example.com/product/my-t-shirt
to https://example.com/my-t-shirt
While WordPress doesn’t provide this option by default, there are solutions to achieve a clean URL structure.
Option 1: Use a Permalink Manager Plugin
The easiest and most reliable way to remove “product” from the URL structure is by using a plugin like Permalink Manager for WooCommerce. This plugin allows you to customize the WooCommerce URL structure, including removing slugs like “product,” “product_category,” and “product_tag.”
- Install the Plugin: Go to Plugins > Add New and search for Permalink Manager for WooCommerce.
- Configure Permalinks: Once installed, go to the plugin settings and choose options to remove or customize the product base.
- Save and Test: Save your new permalink structure and test product links to ensure there are no issues.
Link: Permalink Manager for WooCommerce
- Pros: Simple to set up, flexible URL customization.
- Cons: Adds an additional plugin, which may slightly impact performance.
Option 2: Use Custom Code with Permalink Rewrite Rules
For those comfortable with code, you can add a snippet to your theme’s functions.php
file to adjust permalink structures by removing the product base. Note that custom rewrite rules can sometimes interfere with page URLs or cause compatibility issues with other plugins, so proceed carefully.
Example code to remove the product slug:
add_filter('register_post_type_args', 'remove_product_slug', 10, 2);
function remove_product_slug($args, $post_type) {
if ($post_type === 'product') {
$args['rewrite']['slug'] = '';
}
return $args;
}
function custom_product_rewrite_rule() {
add_rewrite_rule('^([^/]+)(/[0-9]+)?/?$', 'index.php?product=$matches[1]', 'top');
}
add_action('init', 'custom_product_rewrite_rule');
- Pros: No additional plugin required.
- Cons: Requires handling permalink flushes and may require troubleshooting with custom rules.
Important Considerations
- SEO and Redirects: Removing the product base can impact SEO, especially if your site has been live with the default structure for some time. Redirect old URLs to avoid broken links.
- Testing for Conflicts: Removing the “product” base could cause conflicts with pages, posts, or other custom post types, so be sure to test thoroughly.
Conclusion
For a straightforward approach, use Permalink Manager for WooCommerce to remove “product” from your URLs. If you prefer a code-based method, custom rewrite rules can also work but may require additional troubleshooting. These solutions can help achieve a simplified, cleaner WooCommerce URL structure.