Forum Discussion
fazinfar_29104
Nimbostratus
Jan 27, 2009direct the http request to new page
Hello everyone.
I am pretty new on Irules and don't know much about it.
I need to direct the http request to http://www.allforme.com/player
to http://www.allforme.com/maintenance
How can i do this?
Thanks
4 Replies
- Juerg_Wiesmann
Nimbostratus
If you are using a Standard Virtual Server I would recommend using a HTTP Class Profile (finally added to your Virtual)
On Configuration add host to www.allforme.com
and on URI Paths add /player
On the Actions
set send to field to redirect and set Redirect Location to http://www.allforme.com/maintenance
So the user will be directed to the new URL if a Match is made.
If you want the user to stay on the same site you have to use rewrite send it to a pool with the destination Host in it and do a rewrite.
http://www.allforme.com[string map { /player /maintenance } [HTTP::uri]]
This will replace the backend Requests with the new Hostheader and replace the URI Path /player with / maintenance
Good luck
Wiesmann - Juerg_Wiesmann
Nimbostratus
If you are using a Standard Virtual Server I would recommend using a HTTP Class Profile (finally added to your Virtual)
On Configuration add host to www.allforme.com
and on URI Paths add /player
On the Actions
set send to field to redirect and set Redirect Location to http://www.allforme.com/maintenance
So the user will be directed to the new URL if a Match is made.
If you want the user to stay on the same site you have to use rewrite send it to a pool with the destination Host in it and do a rewrite.
http://www.allforme.com[string map { /player /maintenance } [HTTP::uri]]
This will replace the backend Requests with the new Hostheader and replace the URI Path "/player" with "/ maintenance" and keep the rest of the URL
Good luck
Wiesmann - hoolio
Cirrostratus
As Wiesmann suggests, you could use an HTTP class to perform the redirection if you're on 9.4 or higher. Else, you could use a simple iRule.
For rewriting the request (as opposed to redirecting to a new location)...
According to RFC2616 you can use a fully qualified reference in the URI. The server must then ignore the host header. But it might be confusing for troubleshooting if you see one hostname in the URI and a different one in the host header. To avoid this, you could use 'HTTP::header replace Host $new_host' to update the host header and HTTP::uri to update the URI:
HTTP::header replace Host "www.allforme.com"
HTTP::uri [string map { /player /maintenance } [HTTP::uri]]
Aaron - Jennifer_Davis2
Nimbostratus
HTTP redirect is not sent to the client, however the URI changes on its way to the pool member
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/player" } {
HTTP::uri "/maintenance "
}
else {pool XYZ}
}
HTTP redirect is sent to the client. Matching on URI.
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/player" } {
HTTP::redirect "http://www.allforme.com/maintenance"
}
else {pool XYZ}
}
HTTP redirect is sent to the client. Matching on both host and URI.
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/player" and [HTTP::host] contains "allforme.com"} {
HTTP::redirect "http://www.allforme.com/maintenance"
}
else {pool XYZ}
}
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
