Forum Discussion
iRule issues
- Sep 24, 2015
Hello,
Welcome to DevCentral.
It seems like you're not using the correct function in your conditional IF-statement. That means, the block of code inside your conditional statement will never be processed. I've added a few comments to the code so you can get started with the most typical functions for HTTP services.
when HTTP_REQUEST { What's the difference of URL, Host, URI, Path, Query? URL = www.abc.com/asd/asd?asd111=11 [HTTP::host] function of this URL would return "www.abc.com" [HTTP::path] function of this URL would return "/asd/asd" [HTTP::uri] function of this URL would return "/asd/asd?asd111=11" [HTTP::query] function of this URL would return "asd111=11" The correct version of this code can be found below. Tip: by using HTTP::redirect you always issue a 302 redirect. I don't recommend this function at all. Instead, I recommend you get used to a slightly harder alternative, HTTP::respond which allows you to have a direct control of the redirect method and optinal HTTP headers if you wish to include them with the redirect. if { [HTTP::host] contains "www.abc.def" }{ HTTP::respond 301 location "http://www.abc.com" } }
Hello,
Welcome to DevCentral.
It seems like you're not using the correct function in your conditional IF-statement. That means, the block of code inside your conditional statement will never be processed. I've added a few comments to the code so you can get started with the most typical functions for HTTP services.
when HTTP_REQUEST {
What's the difference of URL, Host, URI, Path, Query?
URL = www.abc.com/asd/asd?asd111=11
[HTTP::host] function of this URL would return "www.abc.com"
[HTTP::path] function of this URL would return "/asd/asd"
[HTTP::uri] function of this URL would return "/asd/asd?asd111=11"
[HTTP::query] function of this URL would return "asd111=11"
The correct version of this code can be found below. Tip: by using HTTP::redirect you always issue a 302 redirect. I don't recommend this function at all. Instead, I recommend you get used to a slightly harder alternative, HTTP::respond which allows you to have a direct control of the redirect method and optinal HTTP headers if you wish to include them with the redirect.
if { [HTTP::host] contains "www.abc.def" }{
HTTP::respond 301 location "http://www.abc.com"
}
}
- Ed_SummersSep 24, 2015NimbostratusSorry, just had to comment on how much I like this response. Answers question, provides some great information, easy to read. Tip o' the hat to you sir!
- Lucilius_223799Sep 24, 2015NimbostratusThank you very much for the reply and explanation. This helped me tons and i'll save the information for later use. I'm receiving training for this in the near future and this can help a ton as well!
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