Forum Discussion

Paulo_Moura_134's avatar
Paulo_Moura_134
Icon for Nimbostratus rankNimbostratus
Apr 03, 2019

Redirecting an specific URI to another one on the same domain

Hi all,

 

I'm trying redirect an specific URI to home page, but it's not working fine.

 

I have te following iRule configured:

 

when HTTP_REQUEST { if { ([HTTP::host] equals "subdomain.domain.com") and ([HTTP::uri] ends_with "/identityiq/dashboard/editPreferences.jsf") } { HTTP::redirect "https://[HTTP::host]/identityiq/home.jsf" } }

 

The objective is "block", doing a redirect on URI /identityiq/dashboard/editPreferences.jsf redirecting to /identityiq/home.jsf

 

1 Reply

  • Hi Paulo,

    for a redirect within a given website site (aka. same protocol and hostname:port), you don't need to specify the protocol, hostname:port). Redirect destination starting with a / (slash) are always considered relativ to the website root-web.

     

    when HTTP_REQUEST { 
        if { ( [string tolower [HTTP::host]] equals "subdomain.domain.com" ) 
         and ( [string tolower [HTTP::path]] equals "/identityiq/dashboard/editpreferences.jsf" ) } then { 
            HTTP::redirect "/identityiq/home.jsf" 
        }
    }
    

     

    Note: Other interesting redirect shortcuts are "//domain.de/folder/file" (same protocol as before but new host/folder/file), "./file" same protocol, same host, same folder(s) but different file)

    Note: You have mentioned that this code has security purposes. Because of that I've added [string tolower] syntax to make the comparsion case insensitive and also changed the matching for the blocked URL to [HTTP::path] equals /.... Without those tweaks the blocking mechanism can be bypassed very easy.

    Cheers, Kai