Cannot get a simple URI redirect working
andimorris
Member ✭
in aFleX
Hi all,
I've been searching through examples on here, the alfex github, the samples on the ACOS device, but just cannot get a simple redirect working with AFlex. Can somebody please point me in the right direction?
I'm trying to do the following
The user visits https://hostname.domain.com and the ACOS device redirects them to https://hostname.domain.com/devicepage
I currently have the following (hostname and domain are substituted for the real ones of course:
# redirect HTTP request to device-reg page
when HTTP_REQUEST {
HTTP::respond 302 Location "https://hostname.domain.com/devicepage"
}
However the result I get is that the user gets redirected infinitely to:
https://hostname.domain.com/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/....
I guess I need some sort of check first to see if the URI is already devicepage/, but any time I try to implement this the AFlex syntax fails.
I've been searching through examples on here, the alfex github, the samples on the ACOS device, but just cannot get a simple redirect working with AFlex. Can somebody please point me in the right direction?
I'm trying to do the following
The user visits https://hostname.domain.com and the ACOS device redirects them to https://hostname.domain.com/devicepage
I currently have the following (hostname and domain are substituted for the real ones of course:
# redirect HTTP request to device-reg page
when HTTP_REQUEST {
HTTP::respond 302 Location "https://hostname.domain.com/devicepage"
}
However the result I get is that the user gets redirected infinitely to:
https://hostname.domain.com/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/....
I guess I need some sort of check first to see if the URI is already devicepage/, but any time I try to implement this the AFlex syntax fails.
Tagged:
0
Comments
# first check if the URI starts with "/devicepage"
# if not redirect to <hostname>/devicepage<original URI>
when HTTP_REQUEST {
if { not ([HTTP::uri] starts_with "/devicepage") }
HTTP::respond 302 Location “https://[HTTP::host]/devicepage[HTTP::uri]”
}