Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How to redirect request without losing query string aem dispatcher

Avatar

Level 2

How can i redirect the request in dispatcher with query parameters from one page to another page without losing query parameters, for example, redirect should take place from

 

https://www.mysite.com/content/us/en/firstpage.htm?a=xyz

 

to 

 

https://www.mysite.com/content/us/en/secondpage.htm?a=xyz

 

 

 

Appreciated any inputs and pointers.

3 Replies

Avatar

Level 4

Hello,

I never had this use case, but looking at the Apache docs, I think you need to use the QSA flag. Something like this:

 

RewriteRule ^my-url/([A-Za-z0-9-_]+)/?$ recirect-url&app=$1 [L,QSA]

 

 

Link to Apache docs: https://httpd.apache.org/docs/2.2/en/rewrite/flags.html#flag_qsa

 

Hope it helps,

Daniel

Avatar

Administrator

@imalakaamir Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni

Avatar

Level 7

@imalakaamir consider to use the below with regular express 

- mod_rewrite  : for URL rewrite and RewriteCond to capture/rewrite URL-with param