Forum Discussion
iRule - http to https permanent redirection : respond code 301
Currently we are using the F5 inbuilt iRule - _sys_https_redirect , we need a permanent redirection (respond code 301) . can I use belwo iRule ?
when HTTP_REQUEST { HTTP::respond 301 HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
6 Replies
- Stanislas_Piro2
Cumulonimbus
Hi,
the irule must be:
when HTTP_REQUEST { HTTP::respond 301 Location https://[getfield [HTTP::host] ":" 1][HTTP::uri] } - Sabeer_Ali_2389
Altostratus
Thanks let me try it
- Sabeer_Ali_2389
Altostratus
Thanks let me try it
- Sabeer_Ali_2389
Altostratus
Hi Stanislas,
I have tried it , redirection is happening but still the respond code is 302
- Stanislas_Piro2
Cumulonimbus
I tried the same irule and it is my result:
$ curl http://abc.company.com -vv * Rebuilt URL to: http://abc.company.com/ * Trying 2a02:aaaa:bbbb:cccc:f5::4... * Connected to abc.company.com (2a02:aaaa:bbbb:cccc:f5::4) port 80 (0) > GET / HTTP/1.1 > Host: abc.company.com > User-Agent: curl/7.43.0 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 301 Moved Permanently < Location: https://abc.company.com/ < Server: BigIP * HTTP/1.0 connection set to keep alive! < Connection: Keep-Alive < Content-Length: 0 < * Connection 0 to host abc.company.com left intactDid you flush your browser cache?
- Arie
Altostratus
HTTP 302 should not be cached by the client.
However, I would recommend using something like cURL for testing rather than a browser since it eliminates optimizations and most caching.
curl -I "http://www.domain.com/"The flag
instructs-I
to do acURL
request, which makes it much easier to review the results. Keep in mind thatHEAD
sometimes returns a different response thanHEAD
.GET
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
