Forum Discussion
I apologize, but beyond the .asp to .aspx part, it's not entirely clear how else you want to redirect. However, assuming, I'm assuming you want the following:
if host == 123.abc.com, then
if Request Target Path ends_with .asp or .aspx, then
redirect to www.abc.com[path][query-params], with .asp changed to .aspx
else redirect to knowledge.cibc.com[path][query-params]
else
do not redirect
Adjust the following as needed for your actual requirements:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "123.abc.com" } {
switch -glob "[HTTP::path]" {
"*.asp" {
HTTP::respond 301 Location "https://www.abc.com[HTTP::path]x[HTTP::query]"
}
"*.aspx" {
HTTP::respond 301 Location "https://www.abc.com[HTTP::uri]"
}
default {
HTTP::respond 301 Location "https://knowledge.cibc.com[HTTP::uri]"
}
}
}
}
Notice that I cut your default branch, which made a pool call. If the pool assigned the Virtual Server is already /PROD/po_abc there is no need to explicitly identify the pool here. If the rule doesn't change the pool selection, then the pool assigned to the Virtual Server will automatically be used.
hi Vernon, thanks for your reply. however when you are doing switch command, you cannot use ".asp" and ".aspx" as criteria to determine the action because .asp is same as part of aspx, so if some incoming traffic with http header uri including /xxx.aspx, it will be replaced as /xxxx.aspxx by your irule. that's also the problem I had before.