Forum Discussion

autogun_200714's avatar
autogun_200714
Icon for Nimbostratus rankNimbostratus
May 05, 2015

iRule Redirect URL and change client address

Hi,

 

Im trying to implement an iRule on our corporate BigIP so when the requested URI for domain mydomain.com is /abc - for example http://mydomain.com/abc, I'd like to redirect and rewrite user's client URL to http://mydomain.com/xyz/hi.

 

Lurking the forums, I couldn't find the right way to do so. Can you suggest?

 

Thanks!

 

3 Replies

  • Do you mean something like this?

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/abc" } {
            HTTP::respond 301 Location "http://[HTTP::host]/xyz/hi"
        }
    }
    

    Ciao Stefan ๐Ÿ™‚

  • Do you have a virtual server just for port 80 or also for port 443? And how are the poolmembers configured for each?

    And even if your application is doing some redirects as well, the LB and iRule will be triggered before.

    Please try this again:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/abc" } {
            log local0. "redirect triggered"
            HTTP::respond 301 Location "http://[HTTP::host]/xyz/hi"
        }
    }
    

    You can also try some browser analyze tools like Fiddler or HTTPWatch to verify if the redirect really doesn't be triggered.

    Ciao Stefan ๐Ÿ™‚

  • @Stefan, the iRule works just fine, the problem was between the chair and the keyboard! Thank you so much!