Forum Discussion

scott_poquette_'s avatar
scott_poquette_
Icon for Nimbostratus rankNimbostratus
Aug 02, 2006

How to append www to a url

Anyone know how I would rewrite the following rule for v9.x?

 

 

else if (http_header("Host") starts_with "mysite") {

 

redirect to "http://www.mysite.com/%u"

 

}

 

 

Or is there a better way to append www to a url?

 

 

Thanks

2 Replies

  • You could either redirect to www.mysite.com, or rewrite the request before it's sent to the pool and not send a rediret back to the client.

    Redirect:

    
    when HTTP_REQUEST {
       if { HTTP::host starts_with "mysite" }{
          HTTP::redirect http://www.mysite.com/[HTTP::uri]
       }
    }

    Or you could rewrite the request and send it to the pool:

    
    when HTTP_REQUEST {
       if { HTTP::host starts_with "mysite" }{
          HTTP::host www.mysite.com
       }
    }

    Aaron