Forum Discussion
Using wildcards in uri redirection in iRules
I currently have
when HTTP_REQUEST { if { [HTTP::path] equals "/" } { HTTP::redirect "/toplevel/src/main/webapp/project.html" } }
I need to make it so I can use the subdirectory as a starting point - basically skipping over /toplevel/ as that will change as more projects get added
ex -- instead of starting at mydomain.com/ I need to start at mydomain.com//
and then append the /src/main/webapp/project.html
Thanks
2 Replies
- 0_173149
Nimbostratus
OK -- since I got no feedback - and figured this out - I'll add what I did in case someone else finds themselves in the same problem --
Basically if they don't send the complete url - I'm separating the PATH and the URI an updating it that way.
If anyone has a better suggestion - type in 🙂
thanks
when HTTP_REQUEST {
if { not ( [HTTP::uri] contains "." ) } { HTTP::uri [HTTP::uri]/src/main/webapp/Project.html HTTP::redirect [HTTP::uri] }}
- Arie
Altostratus
Can you clarify the requirements a bit? What you're looking for is certainly doable, but I'm unclear on the precise syntax. Are you saying that all content on the OWS (Origin Web Server) is will be under a root called "toplevel" but that you don't want the user to see that in the URL? If so, what part of the path would indicate which project they're accessing?
Also, it looks like you're assigning a new value to HTTP::uri before using it in the redirect. However, although HTTP::uri can be read, it has a double function in that changing the value is intended to alter the value that's being sent to the OWS. You'll want to either use a variable or use the statement itself in the redirect. The latter would be preferred as it is more efficient.
Lastly, using HTTP::redirect is inefficient as it uses a 302 (temporary redirect) rather than a 301 (permanent redirect). If the redirect for a given URL will always be the same you'll want to use a 301. To accomplish this you need to use
rather thanHTTP::respond
.HTTP::redirectHaving said all that, should it really be a redirect or would it be better to make it transparent to the user? (i.e. route the request to the appropriate resource on the OWS but keep the URL in the browser the same)
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