We use cookies on our website to ensure we provide you with the best experience on our website. By using our website, you agree to the use of cookies for analytics and personalized content.This website uses cookies. More Information
It seems like your browser didn't download the required fonts. Please revise your security settings and try again.
Barracuda Load Balancer

Understanding URL Rewrite Rules

  • Last updated on
Use the WEBSITES > URL Rewrites page to create rules to modify inbound HTTP requests and outbound response rules for Layer 7 - HTTP Services. From this page you can:
  • Create rewrite rules to modify incoming HTTP request headers and URLs
  • Create rewrite rules to modify outbound HTTP response headers
  • Create rules to rewrite any text string in an outbound HTTP response body

 

Once you select a Layer 7 HTTP Service in the WEBSITES > URL Rewrites page,  the page refreshes to show the rules for the selected service.

HTTP Request Rewrite Conditions
A request rewrite condition is made up of one or more expressions. An expression consists of an operand, an operator, and a matching value.

 

An HTTP request rewrite is applied to the HTTP request coming from the client to the Barracuda Load Balancer.


Table 1. HTTP Request Rewrite Operators

Table 1 describes the operators you can use in the request rewrite condition expression:

Operator ValuesDescription
contains, CONTAINS, co, COChecks if the operand contains the matching value.
ncontains, nCONTAINS, nco, nCOChecks if the operand does not contain the matching value.
rcontains, rCONTAINS, rco, rCChecks if the operand contains the matching value, where the matching value is interpreted as a regular expression.
equals, EQUALS, eq, EChecks if the operand is equal to the matching value.
nequals, nEQUALS, neq, nEQChecks if the operand is not equal to the matching value.
requals, rEQUALS, req, rEChecks if the operand is equal to the matching value, where the matching value is interpreted as a regular expression.
exists, EXISTS, ex, EX Checks if the operand exists. No matching value is required.
nexists, nEXISTS, nex, nEXChecks if the operand does not exist. No matching value is required.


Table 2. HTTP Response Rewrite Expression Tokens

Table 2 describes the tokens available for joining expressions:

TokenDescription
or, OR, ||Checks if either of the expressions is true.
and, AND, &Checks if both the expressions are true.
( )Use parentheses to group together multiple expressions.


Table 3. HTTP Response Rewrite Expression Operands

Table 3 describes the possible operands for the expression; all keywords are case insensitive:

OperandsDescriptionExample
Header

Examine the request header. You can search for a header field name, which is a string followed by a colon (:), or for any string. To search for HTTP or custom header field names, type Header followed by the header field name. The header field name to be examined may be a string (e.g. user-agent, accept) or a wildcard (to examine all headers).

To search for any string in the header area, enter that string without the keyword. In all of these cases, the matching value may be a regular expression.

  • Header Accept co soap
  • Header Soap-Action ex
  • AnyString EX
Client IPCheck the IP address of the client that sent the request. The IP address can be either the host IP address or subnet IP address specified by a mask. Only the EQUAL and NOT EQUAL operators may be used with this operand
  • Client-IP eq 192.168.1.0/24 (subnet IP address containing the mask)
  • Client-IP eq 192.168.1.10 (host IP address)
URI The Uniform Resource Identifier (URI) identifies the resource upon which to apply the request. The matching value may be a regular expression.
  • URI rco /abc*html
MethodHTTP method in the request.
  • Method eq GET
HTTP-VersionHTTP protocol version of the request.
  • HTTP-Version eq HTTP/1.1
ParameterThe query portion of the URL which is passed to the server as a name-value pair. $NONAME_PARAM may be used to refer to the case where the parameter name is absent. The matching value may be a regular expression.
  • Parameter sid eq 1234
  • Parameter $NONAME_PARAM co abcd
PathinfoThe portion of URL containing extra information about the path of the resource on the server. The matching value may be a regular expression.
  • pathinfo rco abc*

 

HTTP Response Rewrite Conditions

A response rewrite condition is made up of one or more expressions consisting of an operand, an operator, and a matching value.

 

An HTTP Response rewrite is applied to the HTTP response going out from the servers to the client through the Barracuda Load Balancer.


Table 4. HTTP Response Rewrite Expression Operators

Table 4 describes the operators you can use in the response rewrite condition expression:

Operator ValuesDescription
contains, CONTAINS, co, COChecks if the operand contains the matching value.
ncontains, nCONTAINS, nco, nCOChecks if the operand does not contain the matching value.
rcontains, rCONTAINS, rco, rCChecks if the operand contains the matching value, where the matching value is interpreted as a regular expression.
equals, EQUALS, eq, EChecks if the operand is equal to the matching value.
nequals, nEQUALS, neq, nEQChecks if the operand is not equal to the matching value.
requals, rEQUALS, req, rEChecks if the operand is equal to the matching value, where the matching value is interpreted as a regular expression.
exists, EXISTS, ex, EX Checks if the operand exists. No matching value is required.
nexists, nEXISTS, nex, nEXChecks if the operand does not exist. No matching value is required.


Table 5. HTTP Response Rewrite Expression Tokens

Table 5 describes the expressions available for joining expressions:

TokenDescription
or, OR, ||Checks if either of the expressions is true.
and, AND, &Checks if both the expressions are true.
( )Use parentheses to group together multiple expressions.


Table 6. HTTP Response Rewrite Expression Operands

Table 6 describes the possible operands for the expression; all keywords are case insensitive:

OperandsDescriptionExample
Header

Examine the request header. You can search for a header field name, which is a string followed by a colon (:), or for any string. To search for HTTP or custom header field names, type Header followed by the header field name. The header field name to be examined may be a string (e.g. user-agent, accept) or a wildcard (to examine all headers).

To search for any string in the header area, enter that string without the keyword. In all of these cases, the matching value may be a regular expression.

  • Header Accept co soap
  • Header Soap-Action ex
  • AnyString EX
Response-HeaderExamine the header of the response. You can search for a header field name, which is a string followed by a colon (:), or for any string. 

To search for HTTP or custom header field names, type Response-Header followed by the header field name. The header field name to be examined may be a string (e.g. user-agent, accept) or a wildcard (to examine all headers). 

To search for any string in the header area, enter that string without the keyword. In all of these cases, the matching value may be a regular expression.
  • Response-Header Set-Cookie co sessionid
Status-CodeChecks the status code of the response returned by the server.
  • Status-Code eq 200

 

Response Body Rewrite

You can create rules for searching and replacing any string in the body of outbound responses. Only responses where the content-type begins with text/ (text/html, text/plain, text/javascript, text/css, text/xml) are searched, not flash or applet content. Table 7 lists the response body rewrite values.

Search and replace strings must be text; regular expressions cannot be used. Additionally, because meta-characters such as \r or \n cannot be used, you cannot search and replace any multi-byte character set strings.


Table 7. Response Body Rewrite Values

Table 7 describes the Response Body Rewrite Rule fields:

Field NameDescription
Rule NameEnter a name to identify the rule.
Rule OrderIf there is more than one rule, enter the order of execution; the range is 1 to 128 with '1' executed first.
Host Match

Enter a value matching the Hostname field in the request header. This value can identify a specific host or it can be a wildcard match with a single asterisk (*) anywhere in the hostname, for example:

  • *
  • *.abc.com
  • www.abc.com
URL MatchEnter a value matching the URL field in the request header. The URL Match must start with a slash (/) and can have only one asterisk (*) anywhere in the URL. A value of /* means that the ACL applies for all URLs in that domain. For example:
  • /*
  • /index.html
  • /public/index.html
Search StringEnter the text string on which to search in the response body.
Replace StringEnter the replacement text string.

 

 

For more information on creating URL Rewrite rules, log into the Barracuda Load Balancer web interface, go to the WEBSITES > URL Rewrites page, and click the Help button.

For a Response Body Rewrite example, refer to the article How to Use the Response Rewrite Function to Enable Web Sites for Google Analytics.

Last updated on