WooCommerce-Logo

Removing /product/ from Woocommerce Product Permalinks / Slugs

99% of WooCommerce users would prefer to use beautiful permalinks/slugs for WooCommerce product pages. But also for category pages!

We need a nice pluginRemove slug from custom post type  and some tricks.

After installing this plugin, we go to its settings page:

Remove slug from custom post type settings

Click the Save Changes button, your Woocommerce product page permalinks are now :

http://www.domain.com/productname/

If you want .html instead of /   , simply type in html and save changes.

woocommerce slug html

Now your product page slug should be :

http://www.domain.com/productname.html

Cheers !

In many cases, this plugin works like a charm, but sometimes it won’t work, especially in latest version of WordPress, as you can see, this plugin is not updated for 2 years….

The most typical problem is :

for old products, the slugs were changed successfully, but we can’t create new products, we would encounter 404 error when opening new product pages !

The solution is simple and quite funny:

Just set the publish time to some time long ago, today is 10th Jan. 2014, I set the publish time to 2013. Save it, your product were now “published long ago”, and you will be able to open the page, no 404 error anymore.

woocommerce 404 error

Another typical problem is that:

This plugin applies to all custom post type by default, we can’t exclude it from some other custom post types, like Portfolio (many themes have this sort of custom post type). So solve this, open the .htaccess file on root folder on your site.

# BEGIN REMOVE SLUG CUSTOM POST TYPE RULES
RewriteRule ^product /(.+)/$ /$1 [R=301,L]
RewriteRule ^product_variation/(.+)/$ /$1 [R=301,L]
RewriteRule ^/(.+)/$ /$1 [R=301,L]
RewriteRule ^/(.+)/$ /$1 [R=301,L]
RewriteRule ^portfolio/(.+)/$ /$1 [R=301,L]
# END REMOVE SLUG CUSTOM POST TYPE RULES

As you can see, there are many rules for other custom post types, like product_variation and portfolio. I would like to disable url rewritten for them. So I removed them, this code block becomes:

# BEGIN REMOVE SLUG CUSTOM POST TYPE RULES
RewriteRule ^product /(.+)/$ /$1 [R=301,L]
# END REMOVE SLUG CUSTOM POST TYPE RULES

Note: Don’t remove the 1st and last 2 lines which begins with #

  12Comments

  1. Clanshop   •  

    THanks Jeriff! your post helped us out… Thanks so much! This plugin is perfect!

  2. makeonlineshop   •  

    Hello,

    Can you explain me why I read on other blogs that it is not a good idea to delete “product” form Woocommerce shops url ?

    Can you think about any internal problem ?

    I need to import products after shop migration to woocommerce and I would like to keep the old previous URLs that do not have “product” word.

    Thank you.

    • Jeriff Cheng   •     Author

      it’s not good idea to change the default url structure.
      makes it more difficult for WordPress system to find out the right content for a certain url.
      whether http://www.domain.com/product-url/ is a post or product? WordPress needs more time and energy to think about it before displaying the right content.

  3. Alice   •  

    Thank you for the thorough post Jeriff. This plugin is awesome but quite pricey in my opinion.

    For those planning to get this, I would recommend using the coupon code: “ELFTRONIX” to get 7% OFF.

    Cheers!

    • Webmaster   •  

      Wow..I can’t wait to save 7% — thanks

      -_-

  4. Fallen   •  

    Hi Jeriff, this post was really helpful! I read it and showed it to my collegae’s. We downloaded to try the plugin and it works perfect, our shop runs with almost 4000 products… So yes! Thanks so much!

  5. dan   •  

    omg I’m a noob and have been searching for a solution to the 404 error for days. Asked 3-4 ‘developers’ and none could sort it. Changed the publish date as you said and its actually working lol. Thanks so much

    Dan

  6. andy   •  

    Thank you very much Jeriff,

    I get stuck with woocommerce product permanlink every time. Your post really help me alot,

    Thank you!

  7. David   •  

    I understood and did. thank you very much but that’s the question.

    when I put in the permalink / product /% product_cat% it does not open the page vobosche. 404 is not an error. and writes a cyclic forwarding all. you know how to do so has become a reference site / category / product name?

  8. David   •  

    hello. I did not understand the first part of your post. how to remove links from the product?

  9. janfeng   •  

    Hi , Nice ! Ask a question:

    If the ‘product’ modified to ‘shop’, 301 should be how to write ?

Leave a Reply

Your email address will not be published. Required fields are marked *