Forum Discussion
irule to check domain and redirect is not working
when HTTP_REQUEST { if { [HTTP::host] equals "www.data.gov.bh" } { HTTP::uri [string map -nocase {"/" "/wps/portal/data/"} [HTTP::uri]] } elseif { [HTTP::host] equals"www.biciactions.bh" } {HTTP::redirect "http://www.biciactions.bh/wps/portal/BICI" } elseif { [HTTP::host] equals "www.fsupport.gov.bh" } { HTTP::uri "/wps/portal/fsupport/"}
}
please advice why above is not working
18 Replies
- NewTOF501_15047
Nimbostratus
i tried this when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "www.data.gov.bh" { HTTP::redirect "http://www.data.gov.bh/wps/portal/data"} "www.fsupport.gov.bh" { HTTP::redirect "http://www.fsupport.gov.bh/wps/portal/fsupport"} "www.biciactions.bh" { HTTP::redirect "http://www.biciactions.bh/wps/portal/BICI"} } but it is also not working - Sam_Hall
Nimbostratus
In the 1st attempt you are rewriting the uri that goes to the server, but the client thinks they are getting what ever page they actually requested. You are going to end up with a lot of extra path information being injected if for example the client already requested http://www.data.gov.bh/wps/portal/data/ it all looks very wrong.
The second attempt is going to cause redirection loops.
I think what you want is something like... if { [HTTP::host] equals "www.data.gov.bh" and [HTTP::uri] equals "/" } { HTTP::redirect "http://www.data.gov.bh/wps/portal/data" }
- NewTOF501_15047
Nimbostratus
it tried when HTTP_REQUEST { if { [HTTP::host] equals "www.data.gov.bh" and [HTTP::uri] equals "/" } { HTTP::redirect "http://www.data.gov.bh/wps/portal/data" } elseif { [HTTP::host] equals "www.biciactions.bh" and [HTTP::uri] equals "/" } { HTTP::redirect "http://www.biciactions.bh/wps/portal/BICI" } } but still not working - Sam_Hall
Nimbostratus
Are you sure? When I access those domains the redirects seem to be working as expected. When I type www.data.gov.bh into my browser it lands me on http://www.data.gov.bh/wps/portal/data for example. What exactly would you like to happen? - NewTOF501_15047
Nimbostratus
how i can same using switch for multi domains
- Sam_Hall_83788
Nimbostratus
In the 1st attempt you are rewriting the uri that goes to the server, but the client thinks they are getting what ever page they actually requested. You are going to end up with a lot of extra path information being injected if for example the client already requested http://www.data.gov.bh/wps/portal/data/ it all looks very wrong.
The second attempt is going to cause redirection loops.
I think what you want is something like... if { [HTTP::host] equals "www.data.gov.bh" and [HTTP::uri] equals "/" } { HTTP::redirect "http://www.data.gov.bh/wps/portal/data" }
- NewTOF501_15047
Nimbostratus
it tried when HTTP_REQUEST { if { [HTTP::host] equals "www.data.gov.bh" and [HTTP::uri] equals "/" } { HTTP::redirect "http://www.data.gov.bh/wps/portal/data" } elseif { [HTTP::host] equals "www.biciactions.bh" and [HTTP::uri] equals "/" } { HTTP::redirect "http://www.biciactions.bh/wps/portal/BICI" } } but still not working - Sam_Hall_83788
Nimbostratus
Are you sure? When I access those domains the redirects seem to be working as expected. When I type www.data.gov.bh into my browser it lands me on http://www.data.gov.bh/wps/portal/data for example. What exactly would you like to happen? - NewTOF501_15047
Nimbostratus
how i can same using switch for multi domains
- nitass
Employee
thanks i tried below but it does not works
[root@centos1 ~] curl -I http://www.data.gov.bh HTTP/1.0 302 Found Location: http://www.data.gov.bh/wps/portal/data Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@centos1 ~] curl -I http://www.fsupport.gov.bh HTTP/1.0 302 Found Location: http://www.fsupport.gov.bh/wps/portal/fsupport Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@centos1 ~] curl -I http://www.biciactions.bh HTTP/1.0 302 Found Location: http://www.biciactions.bh/wps/portal/BICI Server: BigIP Connection: Keep-Alive Content-Length: 0
have you ever used http analyzer tool? it may be helpful.
HttpFox
https://addons.mozilla.org/en-US/firefox/addon/httpfox/
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