Forum Discussion
irules for reject
The error very likely arises from the lack of spaces in the source code. You have this:
when HTTP_REQUEST {
if{[HTTP::uri] contains"http://www.abc.com"}{
At a minimum, you need a space between if and the open brace, as well as between contains and the following quote ("):
if {[HTTP::uri] contains "http://www.abc.com"}{
or the parser will fail.
As also pointed out above, though, there are a few logic errors. Those won't cause a syntax error, but they will mean your code won't do what you want.
When a person types "; in his browser, the user-agent generates an HTTP Request message. That message will look something like this:
GET / HTTP/1.1
Host: www.abc.com
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
That first line (the one beginning with "GET") is the Start-Line. It is structured as follows:
HTTP::uri retrieves the part. Notice that HTTP::uri specifically does NOT return the URI entered into the user-agent. See the "Elaboration" section in this article for more details:
HTTP::host (a short-hand for HTTP::header value Host) retrieves the "Host" header, which is not embedded in the (and hence, not returned as part of HTTP::uri).
As that iRule recipe also explains, in general, when using HTTP::host, it makes sense to wrap it in string tolower, just as @Jinshu does.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com