Forum Discussion

gr0x_33657's avatar
gr0x_33657
Icon for Nimbostratus rankNimbostratus
Aug 13, 2009

Redirect HOST and URI

I would like to redirect any domains to include www and also keep the URI, for example,

 

 

domain.com/folder2

 

 

to

 

 

www.domain.com/folder2

 

 

I have this rule but it does not keep the URI

 

 

when HTTP_REQUEST {

 

if { !([HTTP::host] starts_with "www.") } {

 

HTTP::redirect "http://[HTTP::host][HTTP::uri]"

 

}

 

}
  • I think I see where the problem is

    try

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

    Hope this helps

    CB