Forum Discussion
Joe_Pipitone
Nimbostratus
Jan 20, 2010SSL redirection and rewrite
I have an iRule currently in place - what we want to do is catch for a URL with a query string that a user clicks on or enters into their browser, and if that URL is accessed insecurely, we need to redirect it securely (http to https)
The URL will look similar to:
http://ourwebsite.org/login/login-page.aspx?src=%7b3961226A-8AB0-4391-ADA1-A85AE2869824%7d
and needs to redirect while still keeping the query string to:
https://ourwebsite.org/login/login-page.aspx?src=%7b3961226A-8AB0-4391-ADA1-A85AE2869824%7d
The only iRule that I could come up with redirects ALL http traffic, but what if I want to redirect if a user goes to /log/login-page.aspx with a query string - can I catch that one and rewrite using https while keeping the URI intact?
when HTTP_REQUEST {
Redirects all to HTTPS keeps URI intact
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
- Joe_Pipitone
Nimbostratus
I was thinking something like this, can anyone tell me if this would work? Would simply adding an asterisk catch any query string?when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/login/login-page.aspx*" { HTTP::redirect "https://ourwebsite.org[HTTP::uri]" } } }
- hoolio
Cirrostratus
HTTP::uri is the path and the query string, so that should work fine. - Joe_Pipitone
Nimbostratus
Thanks - can you tell me whether or not I need the asterisk? - hoolio
Cirrostratus
If you're wanting to match /login/login-page.aspx and anything after that, you'd need the asterisk. You could also use HTTP::path and not use the asterisk and -glob flag:when HTTP_REQUEST { switch [string tolower [HTTP::path]] { "/login/login-page.aspx" { HTTP::redirect "https://ourwebsite.org[HTTP::uri]" } } }
- Joe_Pipitone
Nimbostratus
Thanks!!!! You helped quite a bit!
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