Forum Discussion
iRule to Redirect to certain directory
I need to create an iRule that will redirect users to a certain directory:
User enters: http://sitename Redirect to: http://sitename/dev/central
I created this iRule:
when HTTP_REQUEST { if { [HTTP::host] equals "sitename"} { HTTP::redirect "sitename/dev/central" } }
When I point my browser to http://sitename, I get redirected to:
http://sitename/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/sitename/dev/central
3 Replies
- nathe
Cirrocumulus
Try changing your redirect line to simply:
HTTP::uri "/dev/central"
And you may consider aging another clause after interrogating the hostname e.g.
& [HTTP::uri] eq "/"
Hope this helps
- Kevin_Stewart
Employee
If I may add, unless you have multiple host names resolving to the same VIP, you could probably skip the host check and just evaluate an empty URI. Something like this:
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect "http://[HTTP::host]/dev/central" } }In the absence of a URI in the browser request (ie. http://sitemame), there is still a URI value, albeit invisible, of "/".
- DaleLeBlanc_140
Nimbostratus
Kevin, your reply worked perfectly. Now, I just need to learn the syntax for iRules and HTTP_REQUESTS ;)
Thanks for your input!
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