Show TOC

Rewriting URLsLocate this document in the navigation structure

Use

Incoming HTTP requests can be modified before they are forwarded to the application server. The URL can also be modified. You can rewrite both the URL path and the query string of an inbound HTTP request into another previously-defined URL path or query string.

Caution Since only normalized URLs are modified and forwarded, the URL rewrite should only be used for applications that are precisely known. With operation RegRewriteRawUrl only URLs in an non-normalized status can be rewritten.

The URL path comprises all characters before the "?" character if a query string comes after the "?".

The query string comprises all characters after the "?" character. A query string comprises all query parameters in a URL. The individual query parameters are separated by a "&".

Example

For HTTP request "/sap/xi/send?client=100&sap-language=de&keep_context", the URL path is "/sap/xi/send", and the query string is "client=100&sap-language=de&keep_context".

A line in the action file describes precisely one modification action. The sequence in the action file defines the sequence of execution too. You can execute multiple URL rewrites consecutively. You can link the execution of HTTP header field modifications to one or more conditions.

Integration

Use the following syntax to define HTTP header field modifications in the action file:

<operation> <pattern> <dest> [<option>]
         

The operation is case-insensitive.

Explanation of the Syntax

<operation>

The modification actions RegRewriteURL and RegIRewriteURL enable you to rewrite the URL of the HTTP request into another URL.

  • RegRewriteURL: The pattern match is case-sensitive.

  • RegIRewriteURL: The pattern match is case-insensitive.

You still have the option of using rewriting the URL to the encoded path. Use the following modification action:

  • RegRewriteRawURL: The pattern match is case-sensitive.
  • RegIRewriteRawURL: The pattern match is case-insensitive.
Caution These two modification actions should not be used for security functions (e.g. URL filters).

<pattern>

Pattern used for the comparison. If query string in the HTTP request contains this pattern, the URL path is rewritten by default to the URL path defined in <dest>. Whether the query string is rewritten or not depends on whether the qsreplace and qsappend options have been specified. If both options are not set, the query string in the HTTP request is not modified.

[<option>]

  • noescape: In this case the result is not URL-encoded. By default the result is always URL-encoded (substitution of special characters: %, /, &). This option is only useful with URL rewrites and URL redirects.

  • restart: Restarts with the first modification action defined. Modification actions already executed remain valid.

  • break:Subsequent modification actions are no longer executed.

  • qsreplace: If the qsreplace option is set, the original query string in the HTTP request is always replaced with the query string defined in <dest>. The query string is also rewritten or enhanced by the set query parameters if the HTTP request does not contain a query string.

  • qsappend: If the option qsappend is set, the original query string in the HTTP request is enhanced with the query string defined in <dest>. The query string is also rewritten or enhanced by the set query parameters if the HTTP request does not contain a query string.

You can specify multiple options consecutively; you separate them using commas. The use of compound (grouping of single modification actions into one block) and skip (skipping modification actions) is no longer recommended.

Example

The following examples illustrate the effects of modification actions on selected HTTP requests.

Example A:

Excerpt from the Action File:

RegRewriteUrl ^/ping/info /sap/public/icman/ping
            

Request before the URL rewrite

Request after the URL rewrite

/ping/info

/sap/public/icman/ping

Example B:

Excerpt from the Action File:

RegIRewriteUrl ^/echo(.*) /sap/bc/echo?header=1
            

Request before the URL rewrite

Request after the URL rewrite

URL path

/echo

/sap/bc/echo?header=1

URL path + query string

/echo?client=100

/sap/bc/echo?client=100

HTTP request contains only the URL path:

If the pattern matches, the URL path /echo of the HTTP request is enhanced by the URL path /sap/bc/echo defined in the action file.

HTTP request contains the URL path and a query string:

In the pattern matches, the URL path /echo of the HTTP request /echo?client=100 is enhanced by the URL path /sap/bc/echo defined in the action file. The query string of the HTTP request is not modified.

Example C:

Excerpt from the Action File:

RegIRewriteUrl ^/echo(.*) /sap/bc/echo?header=1 [qsreplace]
            

Request before the URL rewrite

Request after the URL rewrite

URL path

/echo

/sap/bc/echo?header=1

URL path + query string

/echo?client=100

/sap/bc/echo?header=1

HTTP request contains only the URL path:

If the pattern matches, the URL path /echo of the HTTP request is enhanced by the URL path /sap/bc/echo defined in the action file. Also, the query string header=1 specified in the action file is appended to the URL path.

HTTP request contains the URL path and a query string:

If the pattern matches, the URL path /echo of the HTTP request /echo?client=100 is enhanced by the URL path /sap/bc/echo defined in the action file. Furthermore, the query string specified in the action file overwrites the query string in the inbound HTTP request.

Example D:

Excerpt from the Action File:

RegIRewriteUrl ^/echo(.*) /sap/bc/echo?header=1 [qsappend]
            

Request before the URL rewrite

Request after the URL rewrite

URL path

/echo

/sap/bc/echo?header=1

URL path + query string

/echo?client=100

/sap/bc/echo?client=100&header=1

HTTP request contains only the URL path:

If the pattern matches, the URL path /echo of the HTTP request is enhanced by the URL path /sap/bc/echo defined in the action file.

HTTP request contains the URL path and a query string:

In the pattern matches, the URL path /echo of the HTTP request /echo?client=100 is enhanced by the URL path /sap/bc/echo defined in the action file. Furthermore, the query string in the inbound request is enhanced with the query string specified in the action file.

Example E:

Excerpt from the Action File:

RegRewriteUrl (.*) /path/to$1
            

Request before the URL rewrite

Request after the URL rewrite

URL path + query string

/my/application/with_param('%2Fthis%2Fis%2Fnot%2Fa%2Fpath')

/path/to/my/application/with_param('%2Fthis%2Fis%2Fnot%2Fa%2Fpath')

Excerpt from the Action File:

RegRewriteRawUrl (.*) /path/to$1
            

Request before the URL rewrite

Request after the URL rewrite

URL path + query string

/my/application/with_param('%2Fthis%2Fis%2Fnot%2Fa%2Fpath'

/path/to/my/application/with_param('%2Fthis%2Fis%2Fnot%2Fa%2Fpath')