Forum Discussion
Sunny_81459
Nimbostratus
Sep 16, 2008HTTP redirect
I need urgent help can some iRle expert write for me?
Brief:
currently, if i request https://test.com/groupabc/aarp.jsp is getting redirected to https://test.com/abc/private/xyz.do but as per the code https://test.com/groupabc/aarp.jsp as header referer enabled.
I would like setup redirect, if uri eq "https://test.com/abc/private/xyz.do" and http_refere equals to NULL then it should redirect to https://test.com/groupabc/aarp.jsp
I have configured the following irule but not working.
===============
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc/private/xyz.do" and
( $refer_host ne "" ) } {
HTTP::redirect "https://test.com/groupabc/aarp.jsp"
}
else {
pool test.com
}
}
===============
Following is the sameple rule witch i referred.
====================
class allowed_referers {
"www.companya.com"
"www.companyb.com"
"www.companyc.com"
}
To disallow empty referers remove the ' and $refer_host ne "" ' check
To drop the request without redirecting to a custom image, replace
the HTTP::respond with 'reject'.
when HTTP_REQUEST {
set refer_host [string tolower [URI::host [HTTP::header Referer]]]
if { ( [matchclass [HTTP::path] ends_with $::images] ) and
( $refer_host ne "" ) and
( not [matchclass $refer_host contains $::allowed_referers] ) } {
log local0.NOTICE "hotlink detected from host: $refer_host"
HTTP::respond 301 "Location" "http://[HTTP::host]/hotlink.gif"
}
}
==============
- hoolio
Cirrostratus
I think you need to get the actual value of the Referer header and replace not equal (ne) with eq (equal). Also, HTTP::path would be more accurate if you want to check the path and object in the URI.when HTTP_REQUEST { if { ([string tolower [HTTP::path]] eq "/abc/private/xyz.do") and ([HTTP::header value Referer] eq "") } { HTTP::redirect "https://test.com/groupabc/aarp.jsp" } else { pool test.com } }
- Sunny_81459
Nimbostratus
Hey Aaron, - hoolio
Cirrostratus
Hi Sandy,when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host], [HTTP::uri] with Referer [HTTP::header value Referer]" if { ([string tolower [HTTP::path]] eq "/abc/private/xyz.do") and ([HTTP::header value Referer] eq "") } { log local0. "[IP::client_addr]:[TCP::client_port]: Matched URI with no Referer. Redirecting client." HTTP::redirect "https://test.com/groupabc/aarp.jsp" } else { log local0. "[IP::client_addr]:[TCP::client_port]: Request okay. Using default pool." } }
- Sunny_81459
Nimbostratus
Hi, - Nicolas_Menant
Employee
when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host], [HTTP::uri] with Referer [HTTP::header "Referer"]" if { ([string tolower [HTTP::path]] eq "/abc/private/xyz.do") and ([HTTP::header "Referer"] eq "") } { log local0. "[IP::client_addr]:[TCP::client_port]: Matched URI with no Referer. Redirecting client." HTTP::redirect "https://test.com/groupabc/aarp.jsp" } else { log local0. "[IP::client_addr]:[TCP::client_port]: Request okay. Using default pool." } }
- Nicolas_Menant
Employee
if it doesn't work, this one:HTTP::header exists when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host], [HTTP::uri] with Referer [HTTP::header "Referer"]" if { ([string tolower [HTTP::path]] eq "/abc/private/xyz.do") and (not([HTTP::header exists "Referer"])) } { log local0. "[IP::client_addr]:[TCP::client_port]: Matched URI with no Referer. Redirecting client." HTTP::redirect "https://test.com/groupabc/aarp.jsp" } else { log local0. "[IP::client_addr]:[TCP::client_port]: Request okay. Using default pool." } }
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