Forum Discussion

Joe_Frost_43072's avatar
Joe_Frost_43072
Icon for Nimbostratus rankNimbostratus
May 11, 2007

Redirect based on images to another domain

I'm trying to redirect based on path/uri content to another domain while keeping intact the structure of the request if the uri content is not mached just send to a local pool.

Similair to apache:

RedirectMatch ^/(.*)$ http://www.domain.com/$1

Here is what i have so far:


class apache  {
   ".au"
   ".cab"
   ".exe"
   ".flv"
   ".gif"
   ".jar"
   ".jpg"
   ".png"
   ".zip"
   "/images/"
}

rule live_statics_rule {
   when HTTP_REQUEST {
    if { [ matchclass [HTTP::path] contains $::apache ] } {
          HTTP::redirect "http://img.domain.com"
      }
      else {
          pool live_resin
      }
 }
}

Will this work or do i need more logic to preserve the full uri request on the client side?

1 Reply

  • You would want to include the original URI in the redirect.

    
    rule live_statics_rule {
       when HTTP_REQUEST {
        if { [matchclass [HTTP::path] contains $::apache] } {
              HTTP::redirect "http://img.domain.com[HTTP::path]"
          }
          else {
              pool live_resin
          }
       }
    }

    Aaron