I have a url structure like this where taobao is a page:


I need to change it to like this


I have tried this but it doesn't work

 add_rewrite_rule( 'product/([^/]+)', 'index.php?product=$matches[1]', 'top' );

You Can follow below step :

1) Login to wp-admin

2) Goto the setting in sidebar menu Into permalinks

3) "Common Settings" In select the Post name and "Product Permalinks" automatically set like /product/sample-product/

I hope it's useful.

enter image description here

  • taobao is page name . full url is http://mywebsite.com/taobao/product=11212132 and we don`t want to change any woocommerce default permalinks – Rohit Kishore Mar 6 '17 at 9:11
  • Common Settings in permalinks use can set in post name or not? – Jignesh Patel Mar 6 '17 at 9:19
  • I am update my ans. Just try it. – Jignesh Patel Mar 6 '17 at 9:24

At first, you have a mistake in your URL. it must be /taobao/?product=11212132 (pay attention to the question mark)

I have answered this question here: Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123

  • added this add_rewrite_rule('taobao/?([^/]*)', 'index.php?product=$matches[1]', 'top'); but still dont work. I want to redirect http://website.com/taobao/?item=123123 to http://website.com/taobao/item/123123 – Rohit Kishore Mar 6 '17 at 9:46
  • @RohitKishore You must replace product= with item= – pooria Mar 6 '17 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.