This article describes how to create an expression to retrieve information from one HTTP header and compare it with the value of another HTTP request header. The procedure describes comparing the URL in the Referrer header to the value of the User-Agent header. It uses the Advanced Expression Evaluator feature on AppExpert.
Administrative access to a NetScaler GUI.
Consider that you want to compare the URL in the Referrer and the User-Agent for mobile versions of a website before responding to the client request. The User-Agent in the "User-Agent" header of the request must match the URL from the Referrer. For example, a sample website www.example.com.
To create an expression to retrieve information from one HTTP header and compare it with the value of another HTTP request header, complete the following procedure:
Navigate to the AppExpert node.
Select Advanced Expression Evaluator from the Tools section.
Specify the following expression in the Advanced Expression Evaluator dialog box:
HTTP.REQ.HEADER("User-Agent")==http.REQ.HEADER("Referrer").VALUE(0).REGEX_SELECT(re~(?<=http://www.example.com/).*~)
This expression detects whether the request for the new website (http://www.example.net) has come from http://www.example.com/url and if the URL = User-Agent.
In the Advanced Expression Evaluator dialog box, you can notice that the NetScaler returns "true" or "false" depending on the success of the match.
If the URL matches the User-Agent value, the NetScaler returns "true" as shown in the following screen shot:
If the URL does not match the User-Agent value, the NetScaler returns "false", as shown in the following screen shot: