I want to change my url to the endpoint of slug on categories. Ex:


should be like this:



We can configure it by URL Rewrites

  1. Go to Magento 2 Admin -> Marketing -> SEO & Search -> URL Rewrites
  2. Find the path by searching Request path column.
  3. Remove the cache php bin/magento cache:clean.
  4. Refresh the front-end, click the main menu category then you can see the configured path.

Example I have modified.

Request path men/tops-men/tees-men.htm

Modified path tees-men.htm


You Can Build category URL path by


Modify getUrlPath($category) by Magento Plug-in feature.

Magento 2 - How to remove parent categories slug from subcategory URLs to make it shorter?

  • Thanks for your response, could you please give me the code for getUrlPath($category)? what should i paste? – MGPM Feb 4 '20 at 8:36
  • if In feature if you are using plug-in than u need to modified. – Anas Mansuri Feb 4 '20 at 8:55
  • No i have not any plugin, just need to override Magento – MGPM Feb 4 '20 at 9:16
  • please click above url, there have some one is created module. – Anas Mansuri Feb 4 '20 at 10:45

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.