Forum Discussion
Converting Regex to iRule
I've been tasked with moving our ISAPI rules from the web server to the LTM iRules. I understand ISAPI use regex, however I'm not familiar with that as I need to be so I was hoping to get some feedback here on converting these rules. I'm trying to understand exactly what this rule is doing. It seems as if it’s simply rewriting the host header to show without the www, cms, or even the test portion of the URI. But that doesn't seem to make a lot of sense since the hostheader would need that info to direct the end user to the correct website in IIS. But I could be looking over the obvious.
when HTTP_REQUEST {
switch "[string tolower [HTTP::host]]" {
"test.sitename.us.com" -
"cms.test.sitename.us.com" {
HTTP::header replace "sitename.us.com"
}
}
}
We are using W2K3 servers, IIS6, and Microsoft's Content Management Server. the cms in the URL is where end users, with proper permissions, go to access the content management interface to update their website, and my LTM is version 10.2.0 HF1.
RewriteCond Host: www\.test\.sitename\.us\.com
RewriteHeader Host: .* sitename\.us\.com
RewriteCond Host: cms\.test\.sitename\.us\.com
RewriteHeader Host: .* sitename\.us\.com
Thanks,
Bob
6 Replies
- hoolio
Cirrostratus
Hi Bob,when HTTP_REQUEST { switch "[string tolower [HTTP::host]]" { "test.sitename.us.com" - "cms.test.sitename.us.com" { HTTP::header replace Host "sitename.us.com" } } }
- Bob_10976
Nimbostratus
Thanks Aaron, however that seem to change anything. I'm still being redirected to my production website instead of the content mangement interface of the test site, and I've only have this applied to my test site, which makes it even stanger.when HTTP_REQUEST { switch "[string tolower [HTTP::host]]" { "test.sitename.us.com" - "cms.test.sitename.us.com" { log local0. before:[HTTP::header] HTTP::header replace Host "sitename.us.com" log local0. after:[HTTP::header] } } }
- Michael_Yates
Nimbostratus
It depends on which information you are wanting from the headers: - hoolio
Cirrostratus
I'd guess that the test application includes references to the production site in response headers and/or payload. You could use the iRule Michael referenced to troubleshoot this. Or you could use a browser plugin like Fiddler2 or HttpFox to track this. If you want to rewrite the response headers, you can use an iRule like this: - Bob_10976
Nimbostratus
- hoolio
Cirrostratus
You could rewrite sitename.us.com to cms.test.sitename.us.com in the URI. Here's an example you could combine with the Host header rewriting:when HTTP_REQUEST { if {[HTTP::uri] contains "sitename.us.com"}{ HTTP::uri [string map {sitename.us.com cms.test.sitename.us.com} [HTTP::uri]] } }
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