Forum Discussion
craigvphillips_
Nimbostratus
Apr 06, 2017Tomcat context path URL
Simpe, just want to rewrite the url from http://example.bleh.com to http://example.bleh.com/example.
I am doing the following, it simply doesn't work and i can't get any logging to output so i'm j...
Apr 06, 2017
I might be wrong, but your first example and your rule does not seem to match?
It has not been tested, but this rule should turn http://example.bleh.com to http://example.bleh.com/example.
when RULE_INIT {
set static::domain ".jbhunt.com"
}
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
if { [[HTTP::host] contains $static::domain }{
Get the first field of the host split by "."
set subdomain [getfield [HTTP::host] "." 1]
Change the uri
HTTP::uri "/$subdomain"
}
}
}
Two tips:
- Static is good practice for variables that's not going to change.
- The host header comes in lower case, so there's no need to actually use string to lower.
- I did not see a reason to validate "" against the subdomain variable since you are checking if the host contains ".jbhunt.com". That would would validate that there is a sub domain, right?
/Patrik
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