F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

kgaigl's avatar
kgaigl
Icon for Cirrocumulus rankCirrocumulus
Oct 19, 2025

IRule to block different combinations host/uri

hello together,

we've got a VIP with a lot of CNAME's and a few login-URI's should be blocked, but not all.

so in our Irule we have some Entries like:

 elseif { [HTTP::uri] starts_with "/presse/login"}
		 {
			HTTP::respond 403 

but now we need special Combinations of 

[HTTP::host][HTTP::uri]

could you pls provide me some Example?

I'm not sure if [HTTP::host] matches alo for HTTPS.

Thank you

Karl

1 Reply

  • hi kgaigl​ 

    yes you can use [HTTP::host] for https too

    You should though better use switch instead of if
    check this https://clouddocs.f5.com/api/irules/switch.html

    and this is an example

    when HTTP_REQUEST 
    {
    	switch -- [string tolower [HTTP::host]] 
    	{
    		"www.example.com" -
    		"test.example.com" 
    		{
    			switch -glob -- [string tolower [HTTP::path]] 
    			{
    				"/presse/login*"
    				{
    					HTTP::respond 403
    				}
    			}
    			default 
    			{
    				log local0. "Hit default for [HTTP::path]]"
    			}
    		}
    		"abc.example.com"
    		{
    			log local0. "Hit rule for [HTTP::host]]"
    		}
    		default 
    		{
    			log local0. "Hit default for [HTTP::host]]"
    		}
    	}
    }