uri rewrite or redirect

Hello

I would like to setup an irule to enforce the url used to access a site.

For example, for site http://lab.test.com/login.

If someone tries to alter the url to http://www.lab.test.com/login, they should be redirected to http://lab.test.com/login.

This should be true for any uri that includes www.lab.test.com

So the URI should ALWAYS be /login? If so, then:

when HTTP_REQUEST {
    HTTP::uri "/login"
}

This would forcibly replace any incoming URI with “/login”.

no. It could be anything. I am trying to remove www.

If I type www.lab.test.com/login. I should be redirected to lab.test.com/login

If I type www.lab.test.com/zxw2389s . I should be redirected to lab.test.com/zxw2389s

Ah, so:

when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] ne "lab.test.com" } {
        HTTP::redirect "http://lab.test.com[HTTP::uri]"
    }
}

Great. Thx.