Forum Discussion

tobs_93015's avatar
tobs_93015
Icon for Nimbostratus rankNimbostratus
Feb 19, 2009

Hide/Mask URL using iRule

Hi,

 

 

I would like to mask my home page URL path via an iRule condition because currently when a user navigate to my domain (http://www.mysite.com), it is redirected to an MCMS server base content (http://www.mysite.com/home/default.htm). I would just like to hide or mask that redirected path via iRule code so when a user navigates to my home page, the address bar will only display my domain URL (http://www.mysite.com).

 

 

Illustration:

 

From:

 

http://www.mysite.com/home/default.htm

 

To:

 

http://www.mysite.com

 

 

Can anyone suggests some options I can try?

 

 

In addition to this, I would like to ask what is the difference between HTTP::path and HTTP::uri and which of these will best support my objective (masking the URL)

 

 

Kindly advice, thanks!

 

 

 

  • I can help you with one.

     

     

    url:

     

    http://www.example.com:8080/main/index.jsp?user=test&login=check

     

     

    path:

     

    /main/index.jsp

     

     

    uri:

     

    /main/index.jsp?user=test&login=check

     

     

    host:

     

    www.example.com:8080
  • James_Quinby_46's avatar
    James_Quinby_46
    Historic F5 Account
    tobs -

     

     

    What you're looking for, I think, is the ability to proxy URLs (along the lines of a ProxyPass apache's mod_proxy). Take a look at the irule here:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPass.html

     

     

    Scroll past the rule to the description below and see if this is the functionality you're looking for.

     

  • If you're only worried about that URI then a simple rule like this would suffice:

    when HTTP_REQUEST { 
       if [HTTP::uri == "/"] { 
         HTTP::uri "/home/default.htm" 
       } 
     }

    This simply checks the incoming URI. If it is "/" (i.e. top page of your site) then it silently rewrites the request to /home/default.htm" before passing it onto the server.
  • Hi andrewO

     

     

    Thanks for your reply, you said that the rule you stated will check if the URL entered starts at "/" it will silently rewrite it to "/home/default.html", what do you mean by "silently rewrite it to /home/default.html"?

     

     

    Will the address bar show only my domain (http://www.mysite.com)? Kindly confirm, thanks!

     

  • Hi andrewO

     

     

    Thanks for your reply, you said that the rule you stated will check if the URL entered starts at "/" it will silently rewrite it to "/home/default.html", what do you mean by "silently rewrite it to /home/default.html"?

     

     

    Will the address bar show only my domain (http://www.mysite.com)? Kindly confirm, thanks!
    • Tosin_Omojola's avatar
      Tosin_Omojola
      Icon for Altostratus rankAltostratus

      If I may clarify what AndrewO meant in his reply, he means that the irule would check if the uri IS ( not that it starts with). An irule that checks if the uri STARTS WITH, looks like below:

      when HTTP_REQUEST { 
         if [HTTP::uri starts_with "/"] { 
           HTTP::uri "/home/default.htm" 
         } 
       }
      

      but AndrewO actually meant == or eq ( both of which means equal to ).

      Now, by "silently rewrites" it means the uri "/" would be replaced with "/home/default.htm" and, yes, that is what your browser will display in its address bar, that is, (http://www.mysite.com/home/default.htm)

      Cheers