UniFirst1_22521
Feb 21, 2019Nimbostratus
301 redirect replacing www if present
Trying to create an iRule that will redirect HTTP to HTTPS and remove example incoming would be http://www.unifirst.ca and it would be redirected to https://unifirst.ca with a 301 response not a 302.
I have the following iRule written
when HTTP_REQUEST { if { [string tolower [HTTP::host]] starts_with "; } then { HTTP::respond 301 "Location" "https://[findstr [string tolower [HTTP::host]] "; 4][HTTP::uri]" } else { HTTP::respond 301 "Location" "https://[HTTP::host]][HTTP::uri]" } }
but it gives me the following error in the browser when trying http://unifirst.ca
This page isn’t working unifirst.ca sent an invalid response.
ERR_INVALID_REDIRECT
I have tried with different browsers and get same results.
Any ideas?