Forum Discussion

murali_125469's avatar
murali_125469
Icon for Nimbostratus rankNimbostratus
Oct 17, 2013

URL Redirection with in another complex https to http redirection rule ? please guide me

Hello everyone ,

 

Iam new to this irules but some how figured out to write one obviously it's not working...

 

Requirement :

 

1.Need to redirect multiple urls say "*.something.com" to fixed url with query which has the original url request "redirecting.com/home.html/?u="by the client to another webserver which will serve the message containing link to new url "newsomething.com"

 

I tried this below irule but it's not working any thoughts ?

 

when HTTP_REQUEST { if {[HTTP::host] contains "*something.com"} { HTTP::redirect "http://aredirector.something.com/Home.html?u=[HTTP::host][HTTP::uri]" pool webserver } }

 

1 Reply

  • You were pretty close. You don't need the pool command because you're not proxying the traffic. Here's what it might look like:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] contains "something.com" } {
            HTTP::redirect "http://aredirect.something.com/Home.html?u=[HTTP::host][HTTP::uri]"  
        }
    }
    

    A request for "http://app.something.com/foo" should generate a redirect to "http://aredirect.something.com/Home.html?u=app.something.com/foo"

    There is one thing though that may cause a problem. If the URL you're redirecting to is this same VIP, then you'll find yourself in an endless loop, as all URLs will contain "something.com".