Show TOC

Procedure documentationDefining Conditions Locate this document in the navigation structure

 

You can link the execution of header field and URL manipulations to one or more conditions.

Procedure

Use the following syntax for lines in the action file.

Syntax Syntax

  1. if <string> <compop> <pattern> [op]
End of the code.

The values mean the following:

Name

Meaning and Possible Values

<string>

Element of the request (header field, form field, system-defined values), fixed string, or access to the relevant standard pattern match of the condition predefined directly.

<compop>

Comparison operation: =, !=, <, >, <=, >=, regmatch (pattern match), regimatch (pattern match case insensitive), strcmp (case sensitive character string comparison), stricmp (case insensitive character string comparison).

A predefined ! negates the condition.

<pattern>

Regular expression used for the comparison

[<op>]

(optional)

Joining multiple conditions: Possible operators are and and or. Unlike programming languages the operators here have equal precedence. The operators are processed from left to right.

Following the the operation you can use the keywords noescape, restart, break, compound, and skip (depending on the operation).

For more information, see Rewriting URLs

Example

Excerpt from the Action File

if %{HTTP_HOST} regimatch *.wdf.sap.com [and]

if %{SERVER_PORT} = 80

SetHeader clientProtocol http

Meaning

If the host name (value of the HTTP host header HTTP_HOST) in the HTTP request ends with .wdf.sap.com and the HTTP port of port 80 is (http://xxx.wdf.sap.com:80/...), the header field clientProtocol is set to the value http.

Excerpt from the Action File

If %{REQUEST_METHOD} !stricmp "GET" [AND]

If %{REQUEST_METHOD} !stricmp "POST"

RegForbiddenUrl ^/(.*) -

Meaning

Only requests with GET and POST are permitted as methods. All other requests are rejected.

Excerpt from the Action File

# Rewrite Rules for ICM

If %{REQUEST_METHOD} stricmp "TRACE"

RegForbiddenUrl ^/(.*) -

Meaning

HTTP requests with the TRACE method are rejected.

Excerpt from the Action File

if %{HEADER:USER-AGENT} !regimatch Mozilla/4.0*

RegForbiddenUrl (.*) -

Meaning

Only requests containing the character string Mozilla/4.0 (not case sensitive) are permitted.

Excerpt from the Action File

If %{SERVER_PROTOCOL} !stricmp "https"

RegIRedirectUrl /sap/ (.*) https://%{HTTP_HOST}/sap/ $1 [code=permanent]

Meaning

If the protocol used is not HTTPS, the request is reformulated for HTTPS.