Forum Discussion

D_Murphy_64954's avatar
D_Murphy_64954
Icon for Nimbostratus rankNimbostratus
Apr 19, 2013

URI Handling for Redirection

I have a situation where I need to modify a simple redirect to ideally, include the URI afterwards, but the URI is unknown at the moment. The situation is that I have to compensate for some poorly written code. The code references both the root and www domain. So the URI information is being stripped with the basic redirect as shown below:

 

when HTTP_REQUEST {

 

if {[HTTP::host] contains "mydomain.com"} {

 

HTTP::redirect www.mydomain.com}

 

}

 

 

Is there a way to modify this redirect to include the URI information afterwards and include in the redirection?

 

 

For example:

 

Request comes in for "mydomain.com/doc/?=345673"

 

I need to redirect it to www.mydomain.com/doc/?=345673

 

 

1 Reply

  • There is;

    
    when HTTP_REQUEST {
          if { [string tolower [HTTP::host]] contains "mydomain.com" } {
          HTTP::redirect "www.mydomain.com[HTTP::uri]" }
    }
    

    I've added the string tolower command to avoid any Case issues.