Forum Discussion
irules redirect help required
i have the below irule which will redirect to SSL, the question is how can i change so that http://www.mysite.co.uk/ does not get redirected but remains as http - thanks
when HTTP_REQUEST {
if { !([string tolower [HTTP::host]] starts_with "www.") } {
HTTP::redirect [HTTP::host][HTTP::uri] } else { HTTP::redirect https://[HTTP::host][HTTP::uri] }}
3 Replies
- Hannes_Rapp
Nimbostratus
Hi Mikey,
Try the solution as below:
when HTTP_REQUEST { if { !([string tolower [HTTP::host]] starts_with "www.") } { Probably a typo here? Your redirect destination is a non-standard HTTPS page HTTP::redirect "[HTTP::host][HTTP::uri]" } elseif { [HTTP::host] == "www.mysite.co.uk" } { Step over. Omit any redirections return } else { Default redirect HTTP::redirect "https://[HTTP::host][HTTP::uri]" } } - nitass
Employee
this is just another example.
configuration [root@ve11a:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "www.mysite.co.uk" { return } "www.*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } default { HTTP::redirect "[HTTP::host][HTTP::uri]" } } } } test [root@ve11a:Active:In Sync] config curl -I /">http://172.28.24.10///">/">http://172.28.24.10/// -H "Host: www.mysite.co.uk" HTTP/1.1 200 OK Date: Tue, 25 Nov 2014 13:38:18 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT ETag: "41879c-59-2a9c23c0" Accept-Ranges: bytes Content-Length: 89 Content-Type: text/html; charset=UTF-8 [root@ve11a:Active:In Sync] config curl -I /">http://172.28.24.10///">/">http://172.28.24.10/// -H "Host: mysite.co.uk" HTTP/1.0 302 Found Location: mysite.co.uk/ Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@ve11a:Active:In Sync] config curl -I /">http://172.28.24.10///">/">http://172.28.24.10/// -H "Host: yoursite.co.uk" HTTP/1.0 302 Found Location: yoursite.co.uk/ Server: BigIP Connection: Keep-Alive Content-Length: 0 - mikey_webb
Cirrus
Thanks - yes that was a typo!
This worked however just another query, the original VS is on http only and as you can see everything was previously being redirected to https. The https VS has a member whereas the http VS does not, if i add the same member all works - just for confidence would like confirmation that this will not affect existing traffic
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