Forum Discussion
Julian_Grunnell
Nimbostratus
Sep 12, 2008HTTPS to HTTP redirect with HTTP Class
Hi - can someone help out with the above please, got the following scenario.
HTTP VS
HTTPS VS
1) anyone who goes to http://sitename/ goes to HTTP VS
2) anyone who goes to http://sitename/contact MUST be redirected to HTTPS VS
3) anyone who goes https://sitename WITH THE EXCEPTION of the /contact page MUST goto HTTP VS
I've been looking at the HTTP Class profiles as you can do redirects with them, the problem I have is with a simple redirect if you goto https://sitename/contact it goes into a loop and IE just errors, Safari actually tells you it's looping. ALL other pages are fine.
So I see that you can define URI Paths within the class to match for so I'm trying to add a rule in the HTTPS redirect that says send ALL HTTPS traffic to the HTTP site that DOES NOT match /contact.
I just don't seem to be able to get the regex right for this - anyone help?
Note: also posted a question about this in the iRules section, but I reckon this will work just as well.
Thanks - J.
3 Replies
- hoolio
Cirrostratus
Here is a regex which will match anything not starting with /contact:
^(?!/contact).+$
And here is an option for case insensitive matching:
(?i)^(?!/contact).+$
(?i)^(?!/contact).+$
Options: ^ and $ match at line breaks
Match the remainder of the regex with the options: case insensitive (i) «(?i)»
Assert position at the start of the string or after a line break character «^»
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!/contact)»
Match the characters "/contact" literally «/contact»
Match any single character that is not a line break character «.+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Assert position at the end of the string or before a line break character «$»
Aaron - Julian_Grunnell
Nimbostratus
Thanks Aaron - you save the day again!!
What was frustrating is the LTM guide states that the LTM's use "ARE / Advanced Regular Expressions" and the examples were very basic. I just couldn't find any decent documentation on "ARE" - saying that I'm no expert on regex at all, so maybe there isn't a great deal of difference?
I'll study your very simple response and try to understand exactly what it's doing.
Thanks again - J. - hoolio
Cirrostratus
Glad it's working for you. Lookaheads and lookbehinds are a bit more advanced than what I'd expect a manual to cover.
ASM uses perl compatible regexes (PCRE). I think the HTTP class evaluation is probably done by TMM using the TCL library, but that's an assumption.
Aaron
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