cancel
Showing results for 
Search instead for 
Did you mean: 

How to redirect any request for /products/product-url to /product-url ?

How to redirect any request for /products/product-url to /product-url ?

I want to move from my old site that all product urls are /products/product-url to Magento 2 site that use /product-url format.

Example

www.example.com/products/jacket1` redirect to `www.example.com/jacket1
www.example.com/products/jacket2` redirect to `www.example.com/jacket2
www.example.com/products/tool1` redirect to `www.example.com/tool1

and so on ....

Note 1. My old site have a lot of products so I want to use a kind of rewrite rule pattern to achieve this.

Example

www.example.com/products/%anything% redirects to www.example.com/%anything%

Note 2. I don't want to use .htaccess, I prefer to achieve this using a module instead!

This answer in Magento StackExchange

2 REPLIES 2

Re: How to redirect any request for /products/product-url to /product-url ?

@Galanis

 

you need to create custom router for that.

 

More info you can find it

 

https://github.com/zoransalamun/magento2-custom-router/blob/master/Controller/Router.php


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: How to redirect any request for /products/product-url to /product-url ?

@Sunil Patel thank you for your answer, I will try it out.