Help: Force to use DNS name

I have been looking for a while, but cannot locate any information. Is there a way one can use and irule to force a user to use dns as apposed to an IP address to connect to a server? Any help would be appreciated.

Thanks!

I am currently using version 9.

Hi Ronnie,

You could check the Host header value for at least one alpha character. If there isn’t one, then redirect to a hardcoded hostname with the original URI:

when HTTP_REQUEST { 
  
     Check if host header value contains at least one alpha character 
    if { not ([ string match -nocase "*\[a-z\]*" [HTTP::host] ])}{ 
  
        Redirect client to the correct hostname, preserving the original URI 
       HTTP::redirect "http://www.example.com[HTTP::uri] 
    } 
 }

Aaron

Thanks for your help, it will work for DNS requests as described. I guess I didn’t explain very well.

We are trying to redirect all users using www.example.com to example.com.

If you want to redirect a client that requests www.example.com to example.com, you could use an iRule like this:

when HTTP_REQUEST { 
  
     Check requested hostname (set to lower case) 
    if {[string tolower [HTTP::host]] eq "www.example.com"}{ 
  
        Redirect client to example.com with the same URI 
       HTTP::redirect "http://example.com[HTTP::uri] 
    } 
 }

If this is for an HTTPS virtual server that both www.example.com and example.com resolve to, you would need to get a cert which is valid for example.com and www.example.com. You can get a ‘Unified Communications Certificate’ for this. Try searching these forums or the internet for details on this.

Aaron