Forum Discussion
redirect http requests to https
Hi Guys, I have a two vips one is at 443 and another one dummy vip with same address at port 80 for http traffic. when users go to all works fine. with other vip if user goes http://domain.com, it is redirecting to https but SSL are lost. here is the Irule when HTTP_REQUEST {
HTTP::redirect https://[HTTP::host][HTTP::uri] }
in order to solve this issues I am planning to add add "www" like this in the below script. As I dont have test environment setup i want to confirm with some experts before i try. Any suggestion are also welcome.
when HTTP_REQUEST { HTTP::redirect ".[HTTP::host][HTTP::uri]" } }
- Dylan_375544
Cirrocumulus
There is actually an iRule built into BIG-IP for that purpose.
HERE is actually a DevCentral article on it with some good info in the comments.
Hope that helps! If it does please up-vote and select this answer, it'd be greatly appreciated!
-Dylan
- JG
Cumulonimbus
Try this one:
when HTTP_REQUEST { if { not ([string tolower [HTTP::host]] starts_with "www.") } { HTTP::redirect "https://www.[HTTP::host][HTTP::uri]" } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
.
Hi SP,
if is the only web application on the IP, then simply redirect to a fixed HOST-value. It will work in any case...
when HTTP_REQUEST { HTTP::respond 301 "Location" "https://www.domain.com[HTTP::uri]" HTTP::respond 302 "Location" "https://www.domain.com[HTTP::uri]" }
Note: If you don't use HTTP to access your web site and also not plan to use it in the future, then it would be far more elegant to send a 301 (Permanent Redirect) instead of 302 (Temporary Redirect) response. The
command can only send 301 (Temporary Redirect) responses, but theHTTP::redirect
command can either send aHTTP::respond
or301
redirect response (see example above).302
Cheers, Kai
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com