Forum Discussion

KD_48848's avatar
KD_48848
Icon for Nimbostratus rankNimbostratus
Sep 10, 2008

URI Rewrite

Currently www.abc.com/login.html is getting redirected to www.abc.com/private/login.html as per the code.

 

 

We have one authentication server in between which matches "/private/" in the uri and if matches the keyword 'private' then it will skip the authentication process.

 

 

So if request are coming directly to www.abc.com/private/login.html, it is not authenticating with the authentication server.

 

 

We need to place a redirect where it will match the "www.abc.com/private/login.html" and should rewrite the uri to "www.abc.com/login.html"

 

 

We have tried to add a simple rewrite ans the host portion is the same.

 

 

Any one has any idea on how to achieve this.

 

 

Thanks in advance.

 

 

 

 

Thanks,

 

KD.

 

2 Replies

  • If you want to rewrite /private/login.html to /login.html, you can use a rule like this:

     
     when HTTP_REQUEST { 
      
         Check if requested URI is /private/login.html 
        if {[HTTP::uri] eq "/private/login.html"}{ 
      
            Rewrite URI to /login.html 
           HTTP::uri "/login.html" 
        } 
     } 
     

    This will rewrite the URI. If for some reason there is a query string for /private/login.html, it wouldn't get rewritten. If you want to rewrite the path (URI minus the query string), change both HTTP::uri's to HTTP::path.

    Aaron
  • And if you want to experiment with rewrites in general, Don wrote a handy little app to generate the rule for you:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=169

     

    Click here