How to redirect request without losing query string aem dispatcher | Community
Skip to main content
Level 2
September 22, 2024
Solved

How to redirect request without losing query string aem dispatcher

  • September 22, 2024
  • 3 replies
  • 1361 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by daniel-strmecki

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

3 replies

daniel-strmecki
Community Advisor and Adobe Champion
daniel-strmeckiCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
September 22, 2024

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

kautuk_sahni
Community Manager
Community Manager
September 25, 2024

@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
RiteshY18
Community Advisor
Community Advisor
September 26, 2024

@imalakaamir consider to use the below with regular express 

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