HTTP::respond 301

An iRule newbie!

I want to perform a 301 redirect. I have a domain ‘somedomain.com’ that I want redirected with an HTTP 301 to ‘www.somedomain.com.’ The two uri’s reference separate virtual servers so the iRule will only be applied to requests for somedomain.com. The iRule is as follows:

when HTTP_REQUEST {

if {[HTTP::uri] contains “domain.com” }{

HTTP::respond 301 Location “http://www.somedomain.com”

}

}

It does not work. When I try to browse to somedomain.com, I receive an HTTP/1.1 200 response from the real server displaying a page saying that there is an error (which is confusing in its own right)

Help?

Hi,

You might have to try and use HTTP::host instead. HTTP::uri is for anything after the hostname following the /

Sweeeet. That worked a treat. Simple when you know how. Thanks for you help.