Forum Discussion

Mike_Wethington's avatar
Mike_Wethington
Icon for Nimbostratus rankNimbostratus
Aug 27, 2009

301 Redirect

We are moving our datacenter from one location "A" to another location "B". I need to do a 301 redirect from "A" to "B" for all traffic. The URL is staying the same the only thing changing is the IP address. I have tried the irule below but I get a page cannot be found error instead of the page. I used wire shark to trap the packets and the server responds with the permanetly moved 301. Both site "A" and "B" are behing big-ip's Can anyone help me with this?

 

 

 

when HTTP_REQUEST {

 

HTTP::respond 301 "192.168.1.1" "http://[HTTP::host][HTTP::uri]"

 

}

 

 

1 Reply

  • If the only thing that is changing is the IP address the hostname resolves to, you'll need to change the A record for the fully qualified domain name. You could try to redirect clients that still have the old IP address to the new IP address, but if the app then references the hostname, they'll still make requests to the old IP address they have cached.

    If you do want to redirect to the new IP address, you can use this rule. You won't want to use a 301 as the client should use the FQDN not the new IP address to make requests to the application.

     
     when HTTP_REQUEST { 
      
         Redirect to new server IP with same URI 
        HTTP::redirect "http://192.168.1.1[HTTP::uri]" 
     } 
     

    Aaron