22-Apr-2020
08:29
- last edited on
04-Jun-2023
21:29
by
JimmyPackets
Hello! I currently have a working maintenance page, however the customer wants it if you go to a specific URL, you get redirected, else you get the page.
Currently, I have been doing redirects for a bunch of URL's in the following way...
when HTTP_REQUEST {
set httppath [string tolower [HTTP::host][HTTP::uri]]
switch -glob $httppath {
"*example.com*" {
HTTP::redirect https://[string map {"example" "example.new.com"} $httppath] }
}
}
}
That irule has been working and have no issues. However, now we are trying to introduce a maintenance page. They want it to be where if you go to a specific site, you redirect, else everything hits the page. I've tried adding the following, but get syntax errors...
when HTTP_REQUEST {
if {set httppath [string tolower [HTTP::host][HTTP::uri]]
switch -glob $httppath {
"*example.com*" {
HTTP::redirect https://[string map {"example" "example.new.com"} $httppath] }
else {
{HTTP::respond 200 content [ifile get "page.html"] }
}
}
I've tried a few other iterations, however i'm stumped at this point and looking for help.
Solved! Go to Solution.
23-Apr-2020
07:28
- last edited on
04-Jun-2023
21:29
by
JimmyPackets
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::host][HTTP::uri]] {
"*example.com*" { HTTP::redirect https://example.new.com[HTTP::uri] }
default { HTTP::respond 200 content [ifile get "page.html"] }
}
}
23-Apr-2020
07:28
- last edited on
04-Jun-2023
21:29
by
JimmyPackets
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::host][HTTP::uri]] {
"*example.com*" { HTTP::redirect https://example.new.com[HTTP::uri] }
default { HTTP::respond 200 content [ifile get "page.html"] }
}
}
23-Apr-2020 07:38
Thank you sir! That worked perfectly!
23-Apr-2020 07:47
01-Aug-2022 22:25
This is similar to a step in the solution Ive been having no success in...
Is this applicable to use the format?
Redirect TLS 1.1/1.2 clients & Append the incoming URL to the redirect target