Forum Discussion

Dipx's avatar
Dipx
Icon for Nimbostratus rankNimbostratus
Aug 01, 2021

Redirect domains to another domain with exclusion in URI

Hello,

 

I'm new to f5 technologies, I would need help to create an iRule for the below requirements.

 

Client requests to web1.com should redirect to web2.com ( Web2.com is on different environment )

 

 

Client request for some URI, such as web1.com/feedback and web1.com/about should not redirect.

 

Can anyone help me to create an iRule for the above requirement.

 

 

2 Replies

  • Hi Dipx,

    Create a datagruop and add the excluded URIs.

    Change the datagroup name in the below iRule.

    when HTTP_REQUEST {
    	if { [HTTP::host] equals "web1.com" && not [class_match [string tolower [HTTP::uri]] starts_with datagroupname] } {
    		HTTP::redirect https://web2.com[HTTP::uri]
    	}
    }

    You can use equals or start_with as per your need.

    Datagroup strings must start with /

  • Dipx's avatar
    Dipx
    Icon for Nimbostratus rankNimbostratus

    Hello Enes,

    It worked, but slight changes required.

    However, rule is not working Chrome browser

    when HTTP_REQUEST {
    	if { [HTTP::host] equals "web1.com" && not [matchclass [string tolower [HTTP::uri]] contains zatca_redirect_exception] } {
    		HTTP::redirect https://web2.com[HTTP::uri]}
    }