Forum Discussion
johns
Employee
Jul 28, 2005Using URI to rewrite host
I am trying to come up with a rule where the first directory name of the uri is used to rewrite the URL. an example will be:
http://www.foo.com/abc/doc/index.html =>
http://abc.foo.com...
johns
Employee
Aug 10, 2005The current rule is:
class file_extensions {
".asp"
".aspx"
".gif"
".htm"
".html"
".jpg"
".js"
".jsp"
}
rule host_rewrite2 {
when HTTP_REQUEST {
set host [HTTP::host]
log local0. $host
set uri [HTTP::uri]
set token [getfield [HTTP::uri] "/" 2]
if { $token eq "" } {
log local0. "no path specified so ignore"
} else {
if { [matchclass $uri ends_with $::file_extensions] > 0 } {
log local0. "Found file request, leave as is!"
} else {
log local0. "Not a file request, update host and check for trailing slash "
set host "$token.$host"
if { $uri ends_with "/" } {
log local0. "Uri ends with a slash, all's good"
} else {
log local0. "Uri doesn't end with a slash, appending one"
append uri "/"
}
}
}
update host
log local0. "host: $host"
log local0. "uri : $uri"
HTTP::header replace "Host" $host
HTTP::uri $uri
}
}
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