Forum Discussion
muzammil_88686
Nimbostratus
Feb 13, 2013Blocking 2 URLs and Allowing 1 URL
Dear Team,
I want to block the below URLs
www.xyz.com/cc_page
www.xyz.com
And want to allow the below URL
www.xyz.com/test_page
Could someone help me with the iRule?
5 Replies
- nathe
Cirrocumulus
muzammil,
Loads of examples of this type of irule on DC.
How about something like this:when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/cc_page" - "/" { drop } } }
This would inherently allow test_page uri.
Or you may want to redirect to test_page thus:when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/cc_page" - "/" { HTTP::redirect "http://[HTTP::host]/test_page" } } }
This probably depends on what other URIs you have and what you want to do with them. Hope this is a good starting point though.
Hope this helps,
N - nathe
Cirrocumulus
muzammil,
That post didn't quite come out as expected. Here are my two options:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
"/cc_page" -
"/" { drop }
}
}
This would inherently allow test_page.
Or something friendlier perhaps:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
"/cc_page" -
"/" { HTTP::redirect "http://[HTTP::host]/test_page" }
}
}
N - muzammil_88686
Nimbostratus
Dear Nathan,
Below iRule which was suggested by you works well.
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
"/cc_page" -
"/" { drop }
}
}
Is there any way to allow only "/test_page" and block all "/*" ? - nathe
Cirrocumulus
How about something with there following:
if { [HTTP::uri] ne "/test_page" } {
drop
} - nathe
Cirrocumulus
You could always use a data group too and do a class match on the contents of this in an irule. This would be useful if you wanted to add further allowed URIs.when HTTP_REQUEST { if { [class match [HTTP::uri] ne "allowed_uris"] } { drop } }
I think in small numbers performance of class match vs switch/if isn't much of a concern but it's another option nonetheless.
Hope this helps,
N
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