Forum Discussion
irule to check domain and redirect is not working
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_15047Jul 07, 2014
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_83788Jul 07, 2014
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_15047Jul 07, 2014
Nimbostratus
how i can same using switch for multi domains - Sam_Hall_83788Jul 07, 2014
Nimbostratus
Like this? if { [HTTP::uri] equals "/" } { 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" } } } - NewTOF501_15047Jul 07, 2014
Nimbostratus
Will it be preferable for performance instead redirect we do [HTTP::uri] /wps/portal/data ? - nitassJul 07, 2014
Employee
i think yes. also, Sam's irule seems to be easier to read and maintain. - NewTOF501_15047Jul 07, 2014
Nimbostratus
thanks i tried below but it does not works if { [HTTP::uri] equals "/" } { switch [string tolower [HTTP::host]] { "www.data.gov.bh" { HTTP::uri "/wps/portal/data" } "www.fsupport.gov.bh" { HTTP::uri "/wps/portal/fsupport" } "www.biciactions.bh" { HTTP::uri "/wps/portal/BICI" } } }
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