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.
- Marcus_10406Oct 18, 2016Nimbostratus
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.
- immuJun 07, 2018Altostratus
Hi Team,
I tried applying the above rule but its giving me error related to brackets and if statement
Can some one please send me the exact rule for asp to *.aspx redirect.
Thanks in anticipation.
- VernonWellsJun 08, 2018Employee
The original was missing a closing brace for the switch. I have updated my original post to include the missing brace, and just tested it. It parses correctly now.