Forum Discussion

jacky_70451's avatar
jacky_70451
Icon for Nimbostratus rankNimbostratus
Jul 23, 2012

URI redirection

Hi all,

 

 

 

I have a requirement to redirect the URI which is not used in our application. We get lot of 404 errors in our apache logs as this URI is bookmarked by the users.

 

 

Actual application URL:https://uat-app.xx.com/ep/faces/index.jspx

 

Old application URL:https://uat-app.xx.com/km/faces/index.jspx

 

 

 

If a user access the URL https://uat-app.xx.com/km/faces/index.jspx or URI /km it should redirect to https://uat-app.xx.com/ep/faces/index.jspx. i am putting the irule which i am going to implement. Please let me know if that will work or not.

 

 

 

 

 

if {[HTTP::uri] starts_with "/km" }{

 

HTTP::redirect https://uat-app.xx.com/ep/faces/index.jspx

 

}

 

 

 

 

4 Replies

  • i think making it more specific might be better. anyway, it is not a big deal.

    if {[HTTP::uri] eq "/km/faces/index.jspx" }{
       HTTP::redirect https://uat-app.xx.com/ep/faces/index.jspx
    }
    
  • Thanks for the quick response nitass.. so what will happen if a user access the URL https://uat-app.xx.com/km/ will that redirect to the actual application page
  • what will happen if a user access the URL https://uat-app.xx.com/km/ will that redirect to the actual application pageno. in that case, you have to use your original irule.
  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    You may want to use a 301 (permanent redirect) rather than a 302 (temporary redirect).

     

     

    HTTP::redirect results in a 302. If you want a 301 you'll need to use:

     

     

     

    HTTP:: respond 302 Location http://destination