Forum Discussion

Davean_Hosang_1's avatar
Davean_Hosang_1
Icon for Nimbostratus rankNimbostratus
Dec 01, 2008

Redirect to URI but keep the host the same

Hello,

 

 

I am trying to redirect all request going to mysite.com and www.mysite.com to a new URI path but keep the host the same.

 

 

Example:

 

if (http_host contains "mysite.com")

 

redirect to "http://%h/maintenance/maintenance.html"

 

use pool serverpool1

 

}

 

else {

 

discard

 

}

 

 

Of course the rule above does not work for me because it keeps redirecting me to the "http://mysite.com/maintenance/maintenance.html"

 

page

 

 

Is this possible?

1 Reply

  • Hi there,

    You shouldn't try to send a redirect and select the pool in the same rule clause. The redirect to command in 4.x should trigger an HTTP redirect to a new location. The browser would make a new request to the new location. The address bar would show the updated URL.

    The pool command would select the pool. Both commands couldn't be used for the same request. The first command should take precedence and the second command wouldn't be used.

    If you want to redirect all requests made with a host header value which contains "mysite.com" where the URI doesn't contain "/maintenance/", and send requests which match the host header check but do contain "/maintenance/" you could do something like this:

     
     if (http_host contains "mysite.com"){ 
        if (http_uri contains "/maintenance/"){ 
           use pool serverpool1 
        } else { 
           redirect to "http://%h/maintenance/maintenance.html" 
        } 
     } else { 
        discard 
     } 
     

    Note: I can't check syntax as I don't have access to a 4.x unit

    Aaron