Forum Discussion

hassan_35513's avatar
hassan_35513
Icon for Nimbostratus rankNimbostratus
Oct 15, 2008

Rewrite IP to Host name

I have client connecting to 1.1.1.1 and I want to rewrite their request to www.mydomain.com. I also have clients going directly to www.mydomain.com.

 

What is the best way to doing it.

 

3 Replies

  • You can redirect to the www.mydomain.com domain if the requested host header isn't www.domain.com:

      
      when HTTP_REQUEST {  
        
          Check if requested host is noto www.mydomain.com  
         if {not ([string tolower [HTTP::host]] eq "www.mydomain.com")}{  
        
             Redirect client to www.mydomain.com  
            HTTP::redirect "http://www.mydomain.com"  
         }  
      }  
      

    If the VIP is HTTPS, you could change the redirect to https://www.mydomain.com.

    Aaron
  • Aaron, Thanks for the quick respone. I don't really want to redirect the client as they are natting my ip on their side. I want to rewrite it

     

     

  • I'm not sure whether it would be more efficient to rewrite all host headers to www.mydomain.com or check if the host header isn't www.mydomain.com and then rewrite it. Here is an example of the latter:

      
      when HTTP_REQUEST {  
        
          Check if requested host is not www.mydomain.com  
         if {not ([string tolower [HTTP::host]] eq "www.mydomain.com")}{  
        
             Rewrite host to www.mydomain.com  
            HTTP::header replace Host "www.mydomain.com"  
         }  
      }  
      

    Aaron