Forum Discussion
Sam_Hall
Jul 07, 2014Nimbostratus
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, 2014Nimbostratusit 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_HallJul 07, 2014NimbostratusAre 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, 2014Nimbostratushow i can same using switch for multi domains
- Sam_HallJul 07, 2014NimbostratusLike 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, 2014NimbostratusWill it be preferable for performance instead redirect we do [HTTP::uri] /wps/portal/data ?
- nitassJul 07, 2014Employeei think yes. also, Sam's irule seems to be easier to read and maintain.
- NewTOF501_15047Jul 07, 2014Nimbostratusthanks 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" } } }