Forum Discussion
Issue with HTTP::URI with trailing /
First off I am an iRule newbie. I am having a bit of an issue with a trailing "/" in a redirect.
when HTTP_REQUEST {
if { [HTTP::uri] equals "/abc/" }{
HTTP::respond 301 Location "">
}
if { [HTTP::uri] equals "/abc" }{
HTTP::respond 301 Location "">
}
This is only a portion of the full rule. The issue is that when entering http://www.thisplace.com/abc the redirect works. However when entering http://www.thisplace.com/abc/, the redirect does not work. There are several other statements in the rule that are working without the trailing "/".
Thanks in advance.
4 Replies
- R_Eastman_13667Historic F5 Account
Change equals to starts_with .
- cpmurphy-3_1754
Nimbostratus
Thank you for your quick reply. However I am curious as to why "equals" does not work? Would use "equals" in conjunction with HTTP::path?
- R_Marc
Nimbostratus
First, a switch statement is probably a better route. They are, I'm told, much faster in iRules than ifs. I'm also not sure what the second part of that responder is about (the ">http...").
This would cover both of the above scenarios:
switch -glob [HTTP::uri] { "/abc*" { HTTP::respond 301 Location " } }Response:
GET /abc HTTP/1.0 HTTP/1.0 301 Moved Permanently Location: ">http://www.someplace.com/blah/blah/ Server: BigIP Connection: close Content-Length: 0 GET /abc/ HTTP/1.0 HTTP/1.0 301 Moved Permanently Location: ">http://www.someplace.com/blah/blah/ Server: BigIP Connection: close Content-Length: 0 - nitass
Employee
>However when entering http://www.thisplace.com/abc/, the redirect does not work. have you ever used http analyzer tool such as httpfox? it may be helpful in troubleshooting. HttpFox https://addons.mozilla.org/en-US/firefox/addon/httpfox/
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