Forum Discussion
IE user agent
Hi!
i have an app that support only IE. i want to display a some message to all browsers except IE. i have found that only IE have a user agent string that contains "Trident". how to write an irule that redirect any except user agent that contains "Trident"?
Thanks,
Aviv Hassidim
I have this irule that open a message page only to user agents that contains some string:
when RULE_INIT { set static::refresh_time 15 set static::notification_page {
System Notification
You are using an unsupported browser and will be redirected to Myspace.com
Wait $static::refresh_time seconds to continue, or click
} } when HTTP_REQUEST { switch -glob [ string tolower [HTTP::header User-Agent]] { "msie 10.0" - "msie 9.0" - "msie 8.0" - "msie 7.0" - "msie 6." { HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" log local0. "Client IP:[IP::client_addr] has been redirected with user agent :[HTTP::header User-Agent]" } default { go to a default location if nothing matches } } }
3 Replies
- Josiah_39459Historic F5 Account
Change this part:
"switch -glob [ string tolower [HTTP::header User-Agent]] { "msie 10.0" - "msie 9.0" - "msie 8.0" - "msie 7.0" - "msie 6." {"
to
if { !([string tolower [HTTP::header User-Agent]] contains "trident") } {
- Aviv
Cirrus
Hi Josiah! i get : error: [command is not valid in the current scope][}] when i replace as u suggested...
- Aviv
Cirrus
Ok! Now is works. This Irule will search for trident is the http request and if there is no such a string it will show an html page with a message that not ie browser is not supported. enjoy!
when RULE_INIT { set static::refresh_time 30 set static::notification_page {
BODY {text-align: center}
<h3>Open This Site Only in IE</h3> `<font color="DarkSlateBlue" Thanks <font color="Teal" **IT Team** } } when HTTP_REQUEST { if { !([string tolower [HTTP::header User-Agent]] contains "trident") } { HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" log local0. "Client IP:[IP::client_addr] has been redirected with user agent :[HTTP::header User-Agent]" } else {`}}
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
