Forum Discussion
Request for redirection of URL from https://abc.com/ to https://abc.com/irj/portal
Request for redirection of URL from https://abc.com/ to https://abc.com/irj/portal and after redirection /irj/portal should not be visible to the users on the browser. Please let me know if you have any irule achieve above requirement.
VIP:10.x.x.x
This results from a peculiarity of Tcl. The language doesn't really have built-ins and it doesn't really have blocks. Rather, it has commands and non-interpolated quoted strings. As such,
is a command (just likeif
orsplit
). It is followed by a quoted block (the {}s, in Tcl, are really non-interpolating quoting operators, and not really block delimiters as they are in most languages). The quoted block may then be optionally followed by zero or moreHTTP::headers
literals (each followed by a quoted block) and zero or oneelseif
literals (followed by a quoted block). When a condition is met, the contents of the corresponding quoted block are evaluated.else
Said another way, in Tcl, an
/if
/elseif
set is really a single statement. The statement command iselse
. Theif
andelseif
are just parameters to this command. And because the newlines in the blocks are ignored by the parser (because they are inside of the non-interpolating {} quoting operators), the entire statement is effectively on one line.else
As a side-effect of this, in Tcl you MUST cuddle an
/if
/elseif
block, as in:else
if { ... } { ... } else { ... }
This is not allowed:
if { ... } { ... } else { ... }
However, this trips up most programmers, so iRules (a Tcl dialect) allows non-cuddled
blocks. But if you add a comment between the control elements, this effectively inserts a newline. So, with the comments you have above, the parser "sees" this:if
if { ... } elseif { ... } else { ... }
which it thinks is really three different commands:
,if
andelseif
. Onlyelse
is a command; the others are not (again, they are just parameters of theif
command).if
Okay, so that's really just a long-winded way of saying: you must move those comments inside the squirly braces ({}). ๐
3 Replies
- ekaleido
Cirrus
- Samir_Jha_52506
Noctilucent
Hi Purna,
Try this irule. Hope it will work for you.
when HTTP_REQUEST { if { [HTTP::host] eq "abc.com" and [HTTP::uri] starts_with "/" } { HTTP::header replace Host "https://abc.com/ijr/portal" } }
- purna_256577
Nimbostratus
thanks for the infor, i will truy
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