Forum Discussion
HTTP Response with iRule
Hello Team
I need help to set iRule to respond 404 page not found. If
1) HTTP request is https://abc.com irule should respond 404 Page not found 2) HTTP request is https://abc.com/test it should load web page.
I tried below iRule but it respond with 404 in both cases
when HTTP_REQUEST {if {[HTTP::uri] equals "abc.com"}{ HTTP::respond 404 content "HTTP ERROR 404 Reason:Not Found" Mime-Type "text/html" }
1 Reply
- Hannes_Rapp
Nimbostratus
"I tried below iRule but it respond with 404 in both cases" This does not sound right. Note that the value of URI you're using in your conditional statement is HTTP path + Query. It's not the same thing as URL.
For your request, use the iRule below:
when HTTP_REQUEST { if {[HTTP::path] equals / }{ HTTP::respond 404 content "HTTP ERROR 404 Reason:Not Found" Mime-Type "text/html" event disable TCP::close } elseif { [string tolower[HTTP::path]] starts_with /test }{ return } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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