Home » WooCommerce: How To Change The Permalink Structure

WooCommerce: How To Change The Permalink Structure

by adminkys

WooCommerce permalink structure may appear unusual for newcomers. Those /product/ and /product-category/ parts of the URL are well-known distinctive features, but some experts don’t agree that this is the most convenient way to handle permalinks SEO-wise. 

A popular thought is to always keep URL structure as simple as possible and remove any unnecessary parts of it. You don’t have to take the word of those experts or me since the official guideline from Google suggest to avoid lengthy URLs with unnecessary parameters. 

So, what does that exactly mean for WooCommerce store builders? 

First of all, URL bases like /shop/, /product-category/ and /product/ can be considered unnecessary as Google knows how to define shop and product pages without the need of specifying that inside the URL. 

And probably you don’t want to create a false perception of site depth for crawlers so they don’t rate those pages lower than they should be. Again, a well-known precept – pages closer to the main folder (domain) are more meaningful for search engines. 

If you agree with such statements, it would be helpful to understand how to redesign the permalink structure in WooCommerce. So read ahead to find out about that. 

What’s the default WooCommerce permalink structure?

Let’s see how permalinks work now and what we can do to make them more user-friendly. 

There are a few things that you must be sure to indicate when creating permalink settings: 

  • product category base (which is /product-category/ by default) 
  • product tag base (/product-tag/ by default) 
  • product page base (could be /product/, /shop/ or any other custom base) 

You have no way to leave these options blank or use the same (/shop/, for example) for both permalinks. Product, category, and tag bases should be unique not to cause conflicts between taxonomies, posts, and pages. 

So, default URLs for shop pages may be the following: 

  • For category pages: site.com/product-category/category-slug 
  • For tag pages: site.com/product-tag/tag-slug 
  • For product pages: site.com/product/product-slug 

Whereas it’s perfectly fine for tag pages (you probably need some base to define the difference between categories and collections), it may be redundant using those bases for category and products page URLs.  

Why consider changing default permalinks

Sometimes WooCommerce users urge to get rid of /product-category/ and /product/ bases or manipulate standard URL structure in other ways. It happens because of two significant reasons:  

  • They wish to see simple and clear URLs, which can also benefit from the SEO standpoint
  • In case of switching from another CMS to WPWoo and desire to keep the same URL structure

It is debatable whether removing those parts of the URL can improve your SEO results. But it’s the most popular reason people are even considering ruining the default permalink structure of WooCommerce. 

There are a few respected sources telling us how to structure permalinks and why shorter URLs are better – Backlinko search engine ranking factors (point #10), Moz best practices for URL structuring (points #6 and #11)

In case you’re starting a new website, it’s safe to run such experiments and see how it helps your SEO. Whereas changing permalinks on an already well-established website could be a risky affair. I’ll explain my concerns further. 

In regard to changing permalinks to match your old website URLs, on the other hand, that seems reasonable and leaves you with more chances not to harm your SEO track record. 

How to remove /product-category/ and /product/ from WooCommerce permalinks

The following methods are safe to use on new websites when you don’t need to play around with 301 redirects to get your users and crawlers to know that URL has been changed.  

The first thing you need to do is go to WP Settings > Permalinks and scroll to “Product category base” and write “.” (dot) as a custom base. 

Then, paste this snippet into your functions.php file: 

add_filter( 'request', function( $vars ) {

    global $wpdb;

    if( ! empty( $vars['pagename'] ) || ! empty( $vars['category_name'] ) || ! empty( $vars['name'] ) || ! empty( $vars['attachment'] ) ) {

        $slug = ! empty( $vars['pagename'] ) ? $vars['pagename'] : ( ! empty( $vars['name'] ) ? $vars['name'] : ( !empty( $vars['category_name'] ) ? $vars['category_name'] : $vars['attachment'] ) );

        $exists = $wpdb->get_var( $wpdb->prepare( "SELECT t.term_id FROM $wpdb->terms t LEFT JOIN $wpdb->term_taxonomy tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'product_cat' AND t.slug = %s" ,array( $slug )));

        if( $exists ){

            $old_vars = $vars;

            $vars = array('product_cat' => $slug );

            if ( !empty( $old_vars['paged'] ) || !empty( $old_vars['page'] ) )

                $vars['paged'] = ! empty( $old_vars['paged'] ) ? $old_vars['paged'] : $old_vars['page'];

            if ( !empty( $old_vars['orderby'] ) )

                    $vars['orderby'] = $old_vars['orderby'];

                if ( !empty( $old_vars['order'] ) )

                    $vars['order'] = $old_vars['order'];    



    return $vars;


Then add a filter to remove /product/ base from product page URL: 

function na_remove_slug( $post_link, $post, $leavename ) {

        if ( 'product' != $post->post_type || 'publish' != $post->post_status ) {

        return $post_link;


        $post_link = str_replace( '/product/', '/', $post_link );

        return $post_link;


add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );

function change_slug_struct( $query ) {

        if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {



                if ( ! empty( $query->query['name'] ) ) {

                $query->set( 'post_type', array( 'post', 'product', 'page' ) );

                } elseif ( ! empty( $query->query['pagename'] ) && false === strpos( $query->query['pagename'], '/' ) ) {

                $query->set( 'post_type', array( 'post', 'product', 'page' ) );

        // We also need to set the name query var since redirect_guess_404_permalink() relies on it.

        $query->set( 'name', $query->query['pagename'] );



add_action( 'pre_get_posts', 'change_slug_struct', 99 );

Snippets were taken from this StackOverflow’s discussion and seemed to work fine for most users except for some cases:

  • Traditional URLs will respond with a 404 error. So if you have those pages indexed previously, be sure to create 301 redirects to corresponding pages. 
  • It may not work with pagination or cause issues with filters, depending on the theme and plugin you use. 

How to set up advanced permalinks rules with Custom Permalinks for WooCommerce

Even though WooCommerce in their documentation warns us about removing /product/, /product-category/, or /shop/ from the URLs, you can go and search for Custom Permalinks for WooCommerce extension inside their official marketplace. It provides you with the safest way to change the default permalink options for categories and product pages. 

A few variants of permalinks for category pages are available here: 

Category slug alone simply means removing /product-category/ part from all URLs, leaving domain + category slug. 

Full path means removing /product-category/ and adding up parent category slug (if the category has one) before corresponding category slug. 

There are also several choices for product pages: 

Product slug alone will remove any excessive part of URL and leave domain + product slug only. 

Product slug with category name will create the most popular version of product URL: domain + category slug + product slug

Full path works the same way as option #2 with one exception – it expands URL with parent category slug if native product category has one. 

This plugin eliminates pagination and filtering issues, it operates independently of your theme and secures you from possible crawler-made consequences. 

The only thing to beware of while changing those permalinks is duplicate URLs. Double-check if you don’t have pages or post types with the same slugs as categories or products. If you find some, be sure to change those slugs to unique to avoid duplicates. 

How to add extensions like .html to URLs

Honestly, I don’t know if there are any benefits or flaws of doing this SEO-wise. But a lot of people are asking for that, so we can’t ignore this topic. 

Probably the main reason you may be looking for a solution for this is migration from another CMS. If you decide to move from another platform to WooCommerce, you might want to replicate your old URLs (e.g. those with .html at the end). 

Of course, you can use 301 redirects to let everyone know about your new URLs, but we often notice a trivial decrease in traffic and SERP positions after filling a website with a bunch of 301 redirects for some time. Probably it has nothing to do with redirects itself because, as Google says, they don’t penalize PageRank for using redirects anymore.

But because of other reasons related to content migration, new UI, and chances of broken links, you may not want to risk and try to recreate the same URLs you had. 

Custom Permalinks for WooCommerce gives you the chance to add any extension at the URL ending, whether it be .html, .php., .htm, or whatever you need:

How to avoid SEO problems after changing permalinks

The tricky part of changing URLs is content duplicates, 404 errors, and redirects. 

When you manipulate URLs on a recently created website without any track record for the domain, page rank, and URLs in Google index, then you have nothing to worry about. You can feel free to perform experiments and pick up any permalink combination that you like. 

But when it comes to changing permalinks on a website with history and high-grade SERP positions, you should carefully double-check these four pillars: 

  1. Are there any pages, posts, taxonomies, custom post types, or other possible entities with the same slug as categories or product pages? If you find some, consider changing slugs to unique ones to avoid conflicts. 
  2. Go to your Google search console and check for pages with 404 responses. If you find some broken links, you should scan the sitemap.xml file for them or any other website pages, where you could manually place old links. 
  3. In case there’s a chance old URLs can still be spotted somewhere, be sure to include the ‘rel=canonical’ tag. That is needed to let crawlers know what page to credit for the content, and then Google won’t punish you for creating duplicates. 
  4. Don’t forget about 301 redirects by no means. It’s crucial for website visitors as well as for crawlers. After you change permalinks, old ones won’t be accessible anymore, so everyone, including crawlers, will be getting 404 errors visiting them. If you changed permalinks with the script, I’d recommend installing the Redirection plugin to handle redirects

But you can sleep well: Custom Permalinks for WooCommerce will create 301 redirects and ‘rel=canonical’ for old URLs once you change permalink structure. And also, in conjunction with the Yoast plugin, they will generate a new sitemap on your behalf with appropriate URLs in it. 


WooCommerce warns us about the consequences of changing permalinks – website slowdown and URL conflicts. But considering that that statement was made a long time ago, and since then, they verified this premium plugin which is doing exactly that thing, maybe WooCommerce changed their mind on permalinks matter. 

Would it help your SEO? 

Well, that’s a more complex question. Some researchers say yes; some SEO experts recommend reducing the number of folders in the path to products and categories and designing shorter URLs. But I leave this decision up to you. Eventually, there’s no absolute truth when it comes to SEO. 

And if you choose to give it a shot, how to do it safely? 

If you are building a new website, you can choose whatever method you like – adding code snippets or installing the plugin, both seem to be safe. Just don’t forget to check if everything is in place in sitemap.xml and if there’re any comments on the Google search console side. 

If you consider manipulations over permalinks on an existing site, I’d strongly recommend you go with the verified plugin. You probably don’t want to tempt fate and mess up with broken links, content duplicates, or accidentally create a redirect loop.

The plugin can cover all of your needs, and available support on WooCommerce.com will help you deal with potential problems. Since permalinks are crucial for SEO, it will be a nightmare to be left alone with such a problem. 

You may also like