Forum Discussion
gusf5_117081
Nimbostratus
May 15, 2013Trying 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
}
}
}
2 Replies
- What_Lies_Bene1
Cirrostratus
Could you post the Class too please? - gusf5_117081
Nimbostratus
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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects