01-Dec-2020 06:05
If user trying to access any page/item which is not present (404) then user should be redirected to home page of site like test123/?abcd=<requested item>
e.g. test123/xyz (HTTP-404) to test123/?abcd=xyz
How to insert the URI in this Irule.
when HTTP_RESPONSE {
if { [HTTP::status] == 404} {
HTTP::redirect "http://test123/?abcd="
}
}
01-Dec-2020 10:21
Hi SS1,
Request : https://www.example.com/path1/path2?param=value
Host : www.example.com
Uri : /path1/path2?param=value
Path : /path1/path2
Query : param=value
https://clouddocs.f5.com/api/irules/HTTP__host.html
https://clouddocs.f5.com/api/irules/HTTP__uri.html
https://clouddocs.f5.com/api/irules/HTTP__path.html
https://clouddocs.f5.com/api/irules/HTTP__query.html
when HTTP_REQUEST {
set uri [string trimleft [HTTP::uri] "/"]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 404} {
HTTP::redirect "http://test123/?abcd=$uri"
}
}
You need trim first slash.
https://devcentral.f5.com/s/articles/irules-101-14-tcl-string-commands-part-2
01-Dec-2020 23:13
Its redirecting to
fdfbglskbvksdfbvlk URI appened in redirect URL but it should be https://test123/?abcd=fdfbglskbvksdfbvlk
02-Dec-2020 05:16
If you want redirect to "https://test123/?abcd=xyz/1234/notfound.aspx"
when HTTP_REQUEST {
set path [string trimleft [HTTP::path] "/"]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 404} {
HTTP::redirect "http://test123/?abcd=$path"
}
}
If you want redirect to "https://test123/?abcd=xyz"
when HTTP_REQUEST {
set val [getfield [HTTP::path] / 2]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 404} {
HTTP::redirect "http://test123/?abcd=$val"
}
}
If you want redirect to "https://test123/?abcd=fdfbglskbvksdfbvlk"
when HTTP_REQUEST {
set val [URI::query [HTTP::uri] item]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 404} {
HTTP::redirect "http://test123/?abcd=$val"
}
}