Trying iRules, new to Ver 11

Hello I am new to version 11 and I am playing with classes for the firs time.

I get this error

01070151:3: Rule [/Common/redirect-staging-test-1] error:

line 1: [command is not valid in the current scope] [class rewrite_domains {

“test.irule.staging.site.com”

}]

Here is the iRule

class rewrite_domains {

“test.irule.staging.site.com”

}

iRule starts

when HTTP_REQUEST {

Check to see if this is a new domain that needs to be silently re-written

set newURI [class match -value [HTTP::host] eq rewrite_domains]

if {$newURI ne “”} {

If it is, re-write the URI to the class matched value, and the host header to the old domain

HTTP::uri $newURI

HTTP::header replace “Host” “staging.site.com”

unset newURI

If it’s not, check to see if it’s someone accessing the old domain incorrectly

} elseif {[HTTP::host] eq “staging.site.com”} {

If it is someone accessing the old domain format, redirect them to the new domain

set redirDom [class match -value [HTTP::path] starts_with redirect_urls]

if {$redirDom ne “”} {

HTTP::redirect “”

unset redirDom

}

}

}

Could you post the Class too please?

I added the following value

Local Traffic ›› iRules : Data Group List ›› rewrite_domains

and created the iRule

when HTTP_REQUEST {

Check to see if this is a new domain that needs to be silently re-written

set newURI [class match -value [HTTP::host] eq rewrite_domains]

if {$newURI ne “”} {

If it is, re-write the URI to the class matched value, and the host header to the old domain

HTTP::uri $newURI

HTTP::header replace “Host” “staging.site.com”

unset newURI

If it’s not, check to see if it’s someone accessing the old domain incorrectly

} elseif {[HTTP::host] eq “staging.site.com”} {

If it is someone accessing the old domain format, redirect them to the new domain

set redirDom [class match -value [HTTP::path] starts_with redirect_urls]

if {$redirDom ne “”} {

HTTP::redirect “https://$redirDom”

unset redirDom

}

}

}

no errors but I cannot make it to change the host when I type

http://test.irule.staging.site.com