Forum Discussion

abeny_894's avatar
abeny_894
Icon for Nimbostratus rankNimbostratus
Oct 29, 2009

URL rewrite

Hi all,

 

 

I have a question on URL re-write,

 

 

can I use i-Rules to re-write the following URL like? if yes, is it the same meaning as redirect? coz after rewrite the URL, http request should be redirected to the mentioned rewrite URL, am I right?

 

 

 

Example:

 

http://www.f5.com ----> VIP ---> http://www.yahoo.com/search?q=www.f5.com

 

 

 

For iRules, how can I archieve this?

 

Thanks a lot

 

 

 

Abeny

2 Replies

  • Hi Abeny,

    A redirect will result in a 301 or 302 status response being sent to the client with a Location header value that indicates to the client where to make a new GET request. The browser address bar will update to show the change in the URL to the Location header value. Rewriting the host and/or URI will be transparent to the client--the change is made before the request is sent to the pool member.

    Here is an example of a redirect:

     
     when HTTP_REQUEST { 
      
         Redirect all requests to http://www.yahoo.com/search?q=$host 
         where $host is the originally requested hostname 
        HTTP::respond 302 noserver Location "http://www.yahoo.com/search?q=[HTTP::host]" 
     } 
     

    And an example for rewriting the host header and URI:

     
     when HTTP_REQUEST { 
      
         Rewrite the hsot header to www.yahoo.com and the  
         uri to /search?q=$host where $host is the originally requested hostname 
        HTTP::header replace "www.yahoo.com" 
        HTTP::uri "/search?q=[HTTP::host]" 
     } 
     

    Aaron