Forum Discussion
iRule to restrict user access to specific URL
I am pretty new to iRules and I have following requirement to restrict user access to single path i.e. https://internal.company.com.au/path/*
If any user tries to access a different path e.g. https://internal.company.com.au/path2/* then they should be redirected to https://internal.company.com.au/path/*
Is this achievable via iRules? Would anyone be able to share a sample code?
1 Reply
Hi N. Tariq,
you may try the iRule below...
when HTTP_REQUEST { if { ( [string tolower "[HTTP::host][HTTP::path]"] starts_with "internal.company.com.au/path/" } then { Allow the request... } else { Redirect the request... HTTP::redirect "https://internal.company.com.au/path/" } }Note: The iRule checks if the requested HTTP host and path starts_with "internal.company.com.au/path/". If this check is true, the iRule allows the ongoing request. If the HTTP host and/or path is different, then it would send a redirect to https://internal.company.com.au/path/.
Cheers, Kai
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