cancel
Showing results for 
Search instead for 
Did you mean: 

SAP WebDispatcher - RegRedirect - QueryString lost

Private_Member_19084
Active Contributor
0 Kudos

Hi experts,

I try to forward an http request to https but there the query string is lost.
Any ideas how to solve this?

Thats how the rule looks.

if %{SERVER_PROTOCOL} !stricmp "https"

RegRedirectUrl /(.*) https://<domain>/$1

If I enter the url http://<domain>/test?parameter=value I get forwarded to https://<domain>/test

So the URL-Parameter gets lost.

I've already tried [QSAPPEND] at the end, but with no effect.

Kind regards

Accepted Solutions (1)

Accepted Solutions (1)

Private_Member_19084
Active Contributor
0 Kudos

A great Thx to everybody for help.

I think the answer is too easy to see it on the 1st view.
After a few tries I got the idea - it is in the header fields.

Just add %{QUERY_STRING} at the end is the solution, this will add the querystring.

To make it to a query-string it is required to add also a ? before.

So the solution for forwarding an old host to a new one combined with an http(s) redirect looks like this:

if %{HTTP_HOST} regimatch host_old.* [and]

if %{SERVER_PROTOCOL} !stricmp "https"

RegRedirectUrl /(.*) https://host_new.company.com/$1?%{QUERY_STRING}

However, I made two statements, to avoid making an URL with just an ? at the end (=query string is empty).

Therefore it looks like this: (1st if query string is available, 2nd if not)

if %{HTTP_HOST} regimatch host_old.* [and]

if %{QUERY_STRING} !stricmp "" [and]

if %{SERVER_PROTOCOL} !stricmp "https"

RegRedirectUrl /(.*) https://host_new.company.com/$1?%{QUERY_STRING}

if %{HTTP_HOST} regimatch host_old.* [and]

if %{SERVER_PROTOCOL} !stricmp "https"

RegRedirectUrl /(.*) https://host_new.company.com/$1

I know icm/http/redirect_## is also a possible solution, but this one is much more mighty and you can make the statements and much more dynamical.

Kind regards and thx again

former_member230159
Contributor
0 Kudos

thanks for sharing the information with us !!

best regards,

Manjunath

Private_Member_19084
Active Contributor
0 Kudos

Sure, thats one of the moments I can share a solution to you ....not the other way

I have to use it

Answers (2)

Answers (2)

jimguo
Advisor
Advisor
0 Kudos

Hi, Query parameters are not preserved when using RegRedirectUrl and options [qsappend][qsreplace] are only available for the RegRewriteUrl/RegIRewriteUrl actions. The options for this scenario are: 1. Use parameter icm/HTTP/redirect_. 2. Use RegRewriteUrl or RegIRewriteUrl. Thanks. Jim

Private_Member_19084
Active Contributor
0 Kudos

Hey Jim,

I already tried with with rewrite, but with this I can't change the host-name and protocol, right?

Kind regards

isaias_freitas
Advisor
Advisor
0 Kudos

Hello,

I'm not sure whether this would work...

But you could try:

if %{SERVER_PROTOCOL} !stricmp "https"

RegRewriteUrl (.*) https://hostname:port$1

Another option would be to use the parameter icm/HTTP/redirect_X to switch the initial connection to HTTPS already.

icm/HTTP/redirect_X = PREFIX=/, FROMPROT=http, PROT=https, HOST=<Web Disp. host>

Thus, all further communication will be in HTTPS and there would be no need for your rewrite rule.

In fact, this sounds more secure. Otherwise, the query string will come unencrypted the first time, and if you want to use HTTPS is because you want to protect it .

Regards,

Isaías

former_member230159
Contributor
0 Kudos

Hi,

Can you please reproduce the issue and paste dev_webdisp trace file here for our analysis.

best regards,

Manjunath

Private_Member_19084
Active Contributor
0 Kudos

Sure...so this is not the expected reaction of the command?
I thought that I miss a command, to also add the query string.

former_member230159
Contributor
0 Kudos

As mentioned by Jim you can use parameter icm/HTTP/redirect_x . you can find documentation here:

icm/HTTP/redirect_&amp;lt;xx&amp;gt; - Administration - SAP Library

best regards,

Manjunath Hanmantgad