Skip to Content
avatar image
Former Member

SAP WebDispatcher - RegRedirect - QueryString lost

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 19, 2016 at 01:22 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 19, 2016 at 08:57 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Jan 18, 2016 at 07:16 PM

    Hi,

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

    best regards,

    Manjunath

    Add comment
    10|10000 characters needed characters exceeded