Forum Discussion
irule to replace any .asp to be .aspx in uri
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.
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.
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
