29-Sep-2020 11:25
I need to redirect one url called usparks.something.ca to https://something.ca/attractions.php and at same time usparks.something.ca/fr to https://something.ca/fr/attractions.php. My Irule looks like this:
when HTTP_REQUEST {
if { [HTTP::host] equals "usparks.something.ca"} {
HTTP::redirect "https://something.ca/attractions.php"
#return
}
elseif {([string tolower [HTTP::uri]] equals "/fr") } {
HTTP::redirect "https://something.ca/fr/attractions.php"
[HTTP::uri]
}
}
But for some reason usparks.something.ca/fr still redirects to https://something.ca/attractions.php not https://something.ca/fr/attractions.php.
Please advise.
Thanks,
Igor
29-Sep-2020
13:39
- last edited on
04-Jun-2023
21:16
by
JimmyPackets
Hi Igor,
You should add HTTP::uri equals "/" comparison. If not add, always "if statement" will run.
when HTTP_REQUEST {
if { [HTTP::host] equals "usparks.something.ca" } {
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://something.ca/attractions.php"
}
elseif { [string tolower [HTTP::uri]] equals "/fr" } {
HTTP::redirect "https://something.ca/fr/attractions.php"
}
}
}
or
when HTTP_REQUEST {
if { [HTTP::host] equals "usparks.something.ca" } {
switch [string tolower [HTTP::uri]] {
"/" { HTTP::redirect "https://something.ca/attractions.php" }
"/fr" { HTTP::redirect "https://something.ca/fr/attractions.php" }
}
}
}