Forum Discussion
HTTP rewrite with uri modification
For easier readability:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains ".csmcosmos.com" } {
set hostname [HTTP::host]
HTTP::uri "/home.html?u=[HTTP::host][HTTP::uri]"
HTTP::header replace Host "aredirector.csmcosmos.com"
pool pool_sharepoint-uat
}
}
when HTTP_RESPONSE {
HTTP::header replace Location hostname
}
If the websites are all hosted on the same server, you shouldn't need the pool command as that's defined in the VIP configuration. Also, your HTTP_RESPONSE event is sending a redirect header to the client to send it back to itself. So for example, if the request is for portal.csmcosmos.com/foo, the URI is changed to to /home.html?u=portal.csmcosmos.com/foo and the Host header is changed to aredirector.csmcosmos.com - which should go to the redirector website based on your host header redirect configuration on the web server. The response from that website will then trigger the insertion of a Location header that points to portal.csmcosmos.com, which probably won't do do anything because the response is a 200 and not a 301 message.
Here's a minor modification of that iRule:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains ".csmcosmos.com" } {
HTTP::uri "/home.html?u=[HTTP::host][HTTP::uri]"
HTTP::header replace Host "aredirector.csmcosmos.com"
}
}
For any request that ends in csmcosmos.com, host header redirection on the web server should send the user to the redirector web site with the altered URI. It's then assumed that the links on that page will send the user to a new URL that does not end with csmcosmos.com.
As for the HTTPS certificate warnings, if you're using a single VIP to host all URLs (old and new), the server certificate in the client SSL profile must either be a SAN (subject Alt Name) certificate, or be using SNI (server name indicator). Otherwise the client will get a mismatch warning when attempting to access a server by name that doesn't match the subject name presented in the server certificate.
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