Forum Discussion

Cory_12946's avatar
Cory_12946
Historic F5 Account
Jan 28, 2011

URL removal

Im sure this is a dumb question but here goes:

 

 

I need a irule/method to do the following:

 

 

client access a vip of any of the following:

 

 

http://www.abc.com https://www.abc.com

 

 

 

rewrite to

 

 

https://abc.com

 

 

Basically need to remove the www.

 

 

Help.

 

 

Thanks

 

  • Hi Cory,

    Do you want the client to see the change in the address bar? If so, you can send the client a redirect to the correct hostname. One possible issue with this approach is that your cert for the HTTPS virtual server must be valid for abc.com and www.abc.com in order to avoid the browser showing a mismatched hostname warning to the user.

    
    when HTTP_REQUEST {
    
        Check if requested host is not abc.com
       if {[string tolower [HTTP::host]] ne "abc.com"}{
    
           Check if the request was mode on port 443
          switch [TCP::local_port] {
             443 {
                set proto https
             }
             default {
                set proto http
             }
          }
           Send the client a 302 redirect with the original URI preserved
          HTTP::redirect "${proto}://abc.com[HTTP::uri]"
       }
    }
    

    Here's a method to rewrite the host header before LTM proxies requests to the pool:

    
    when HTTP_REQUEST {
    
        Check if requested host is not abc.com
       if {[string tolower [HTTP::host]] ne "abc.com"}{
    
           Rewrite the host header
          HTTP::header replace Host "abc.com"
       }
    }
    

    Aaron
  • Cory_12946's avatar
    Cory_12946
    Historic F5 Account
    Thanks hoolio, I think the 2nd one is the way to go. They do not have wildcard certs so that will be an issue.

     

     

    Thanks