Forum Discussion

Hien_Truong's avatar
Aug 31, 2020

redirect some valid pages but set to reset or main page site with other garbage.

Hi,

i need help with redirect irule:

 

if user type the valid uri:

https://mysite.com/work/validpage1 redirect to https://othersite.com/pages

https://mysite.com/work/validpage2 redirect to https://othersite.com/pages

 

but if user type any gargage sites or misspell sites (not valid sites):

https://mysite.com/work/garbage1 redirect to https://mysite.com

https://mysite.com/work/abcdefg1 redirect to https://mysite.com

https://mysite.com/work/valiydpage1 redirect to https://mysite.com

 

i appreciate your help.

Thanks

2 Replies

  • Hi Hien Truong,

    when HTTP_REQUEST {
    	set host [HTTP::host]
    	set uri [string tolower [HTTP::uri]]
    }
     
    when HTTP_RESPONSE {
    	if { $host eq "mysite.com" && $uri starts_with "/work/" } {
    		if { [HTTP::status] eq "200" } {
    			HTTP::redirect "https://othersite.com/pages"
    		}
    		else {
    			HTTP::redirect "https://mysite.com"
    		}
    	}
    }