Forum Discussion
siru_129409
Nimbostratus
Sep 21, 2015url rewriting/redirection
Hi all
I Have a query on URL rewriting/redirection, I have two scenarios as explained below
Scenario 1
users type www.abc.com on browser and We have hosted the site internally as www.xyz.c...
Sep 26, 2015
Hi Siru!
Let's say a user enters www.abc.com and ends up at www.xyz.com/abc. How will you handle the links?
If what you describe is all you want this rule might work:
when HTTP_REQUEST {
Get the middle part of the host
set site [lindex [split [HTTP::host] "."] end-1]
Concatenate midhost to the uri
HTTP::uri "$site/[HTTP::uri]"
Disable the stream filter for requests
STREAM::disable
Remove this header to prevent server from compression response
HTTP::header remove Accept-Encoding
Replace the host header to match www.xyz.com
HTTP::header replace "Host" "www.xyz.com"
}
when HTTP_RESPONSE {
Rewrite the Location header for redirects
if { [HTTP::header exists Location] }{
HTTP::header replace Location [string map {"https://www.xyz.com" "https://www.abc.com"} [HTTP::header Location]]
}
Rewrite the response content using a stream profile if it is text
if { [HTTP::header Content-Type] contains "text" } {
Set the stream expression with the find/replace strings
STREAM::expression "@www.xyz.com@www.abc.com@"
Enable the stream filter
STREAM::enable
}
}
Please note that I have not tested these rules. That's something you need to do yourself. 🙂
/Patrik
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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