Forum Discussion

jaikumar_f5_226's avatar
jaikumar_f5_226
Icon for Nimbostratus rankNimbostratus
Jan 24, 2017

URI Masking if there's multiple redirects

Hi Folks,

I went through a lot of articles in devcentral, but all I could find was for single URI masking without multiple redirects. I have this below requirement.

End User should access and always see --> https://abc.com but the content of https://abc.com/article12

Should not see the URI path's or even track it.

There is a content hosted in URI --> /article12 (So its like https://abc.com/article12) When https://abc.com/article12 is accessed, it redirects to 4-5 different set of URI's. Like I have multiple 302's to reach the end result. Finally I see the content from https://abc.com/article12/libs/granite/core/content/login.html?abcxyzreason=unknown&j_reason_code=unknown

So to achieve 1st requirement I used HTTP_REQUEST, accessing abc.com should goto /article12. But its going on loop.

when HTTP_REQUEST {   
    if { [HTTP::host] eq "abc.com" } {   
       HTTP::uri /article12/  
       } 
} 

I tried to go with the below HTTP Response Irule, but its also going on loop.

when HTTP_RESPONSE { 
if { [HTTP::is_redirect] && [HTTP::header Location] contains "/article12" } { 
    HTTP::header replace Location [string map -nocase "/article12 /" [HTTP::header Location]] 
    }
}

8 Replies

  • Try this to start ;-

    when HTTP_REQUEST { 
        if { [HTTP::host] eq "abc.com" && [HTTP::path] eq "/"} { 
           HTTP::uri /article12/
        } 
    } 
    

    Although it sounds as if your webserver is also performing 302 redirects unders some circumstances......

    • jaikumar_f5's avatar
      jaikumar_f5
      Icon for MVP rankMVP

      Well this helped on the 1st part. Thanks. But need help on URI Masking too. Accessing abc.com went to abc.com/article12 but the URI is seen. I do not want the URI to be seen. Just abc.com should be seen. Please advise. I guess we should be touch the response header ?

       

    • IheartF5_45022's avatar
      IheartF5_45022
      Icon for Nacreous rankNacreous

      No, I suspect this may fix your problem (note have removed trailing /);-

      when HTTP_REQUEST { 
          if { [HTTP::host] eq "abc.com" && [HTTP::path] eq "/"} { 
             HTTP::uri /article12
          } 
      } 
      

      If that doesn't work please explain what is happening ie server is sending a redirect ? What Location header?

    • jaikumar_f5's avatar
      jaikumar_f5
      Icon for MVP rankMVP

      Tried removing the trailing / too, no luck. Still seeing entire URI. I see 302 twice coming from webserver, its a big URI path starting with /article12/libs/granite/