Forum Discussion
Cathi_Hahn_3185
Nimbostratus
Jul 28, 2006Rule to redirect http to https
How do I write a rule to redirect someone from the virtual server "stuff" to the virtual server "stuff-ssl"? We need to force users who do not enter the "https://" to go to the SSL site. I don't normally write code and the samples do not seem to work. Is there another way besides an iRule to do a forced redirect?
Any help would be appreciated.
- hoolio
Cirrostratus
A search for "redirect https" leads to this example:when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
- Cathi_Hahn_3185
Nimbostratus
I tried that rule, but it did not work. I created the rule and associated it to the appropriate pool, but the outcome did not change. I still need to type https to get to the website. - hoolio
Cirrostratus
Hi,when HTTP_REQUEST { log local0. "received request from [IP::remote_addr]. Redirecting to https://[getfield [HTTP::host] ":" 1][HTTP::uri]" HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
- dennypayne
Employee
For your application I would thinkwhen HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }
- Deb_Allen_18Historic F5 AccountFYI: The getfield command splitting hostname on the ":" was included in the codeshare rule to make the rule compatible with http virtuals running on non-standard ports.
- Yoda_34023
Nimbostratus
Hi I just copied and pastes the belowiRule into my device, and it's thrown up errors: - hoolio
Cirrostratus
I just tested this rule:when HTTP_REQUEST { log local0. "received request from [IP::remote_addr]. Redirecting to https://[getfield [HTTP::host] ":" 1][HTTP::uri]" HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
- Yoda_34023
Nimbostratus
Brill that worked cheers.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects