0

I'm trying to do this in Magento 2:

  • I have my url : https://www.example.com/page/
  • I'd like to add after /page a key value. Example : /page/key1, /page/key2 ...
  • Then I get the key value with $this->getUrlParams() and depending of the key value I display something different.

Getting the key value works if I do a rewrite url through Magento 2 Admin but I want to do it programmatically.

Any advice ? If you need more explanation, don't hesitate to tell me.

Thank you!

4
  • hi there, could you please be more specific about Getting the key value works if I do a rewrite url through Magento 2 Admin but I want to do it programmatically.? – Diana Botean Feb 15 at 10:54
  • mageplaza.com/kb/how-to-create-url-rewrites-magento-2.html If I rewrite /page by /page/key1, I can get urlParams and use it in a variable $key = $this->getUrlParams() – ccreusat Feb 15 at 10:57
  • ok yeah, i got that :) but how about the fact that you 'want to do it programmatically'? this can relate to the webserver level, to Magento internal redirection and url creation? which is it? where is the programmatic solution needed? – Diana Botean Feb 15 at 11:10
  • Can't really say. I'm new to backend ... I don't want to rewrite url with admin . I get my param after a post method and use it in an Array to display informations. But when I click on one of my 3 submit buttons, I send param1, param2 or param3. I want to show it to the user (button2 click > url/param2). Is it clear? :) – ccreusat Feb 15 at 12:34

Your Answer

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

Browse other questions tagged or ask your own question.