Forum Discussion
Irule help needed
Hi Guys,
I have a requirement of an irule to achieve the following, will someone kindly help me out.
I have a URL http"//www.service.com/_badlink/*.pdf" i want to block this and throw a page not avaliable message will someone provide quick help here.
Regards,
4 Replies
when HTTP_REQUEST { if {[HTTP::host] eq "[www.service.com](http://www.service.com)" and [HTTP::uri] starts_with "/_badlink/"} { switch -glob [string tolower [HTTP::uri]] { "*.pdf" { set message "illegal file download !!!" HTTP::respond 200 content [subst -nocommands -nobackslashes [ifile get message.html]] noserver "Content-Type" "text/html" } } } }Then, you have to add an ifile containing the html content of your message. You can set $message in your content and it will be replaced by the value of the variable in irule.
- Techgeeeg
Nimbostratus
Thanks Yann can you tell me more about ifile pls also I didn't see the "_badlink" in the irule as I need to block it only for that folder.
Hello, please find below the irule reposted. The badlink is trapped here :
when HTTP_REQUEST { if {[HTTP::host] eq "www.service.com" and [HTTP::uri] starts_with "/_badlink/" } { switch -glob [string tolower [HTTP::uri]] { "*.pdf" { set message "illegal file download !!!" HTTP::respond 200 content [subst -nocommands -nobackslashes [ifile get message.html]] noserver "Content-Type" "text/html" } } } }You can create an ifile by importing your html content in System > File Management > Import ifile
Then you create an ifile object that refer to the ifile content previously imported in Local Traffic > iRules > iFile List. In the irule you refer to the ifile object created in iRules > iFile List tab
For the html content itself, it's up to you to create an html message with your own look&feel. The bonus is that you just have to set $message in the html file where you want the irule to replace this variable by the value.
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