Forum Discussion

winifred_corbet's avatar
winifred_corbet
Icon for Nimbostratus rankNimbostratus
Jun 14, 2007

Simple redirect for home page only

I need to redirect anyone coming in to http://www.somedomain.com to http://www.somedomain.com/cda/homepage.do in the meantime anyone coming in on http://www.somedomain.com/anydirectory still gets to that http://www.somedomain.com/anydorectory and does not get redirected to home page.

 

 

So I am try to just redirect the home page.

 

 

I am new to irules obviously.

2 Replies

  • I assume you just want to redirect based on the URI in the request and not the host. Here's an example that will send a redirect for / to /cda/homepage.do. All other requests will be unchanged.

    
    when HTTP_REQUEST {
       if {[HTTP::path] eq "/"}{
          log local0. "redirecting client [IP::client_addr]"
          HTTP::redirect http://[HTTP::host]/cda/homepage.do
       }
    }

    If you have more tests you want to perform, you could use a switch statement to do the comparisons. Check the wiki page for switch (Click here) for details.

    Also, if you're on version 9.4.0, you can use an HTTP class to issue redirects. Create an HTTP class with a path of "/" and change the 'send to' option to 'redirect to' http://[HTTP::host]/cda/homepage.do.

    Holler if you have any questions.

    Aaron
  • Right, if the URI is just /, nothing else, we need to redirect to /cda/homepage.do. All other URIs do not need to be redirected.

     

     

    We are on v9.2.3 still, but sounds like HTTP class feaure in v9.4.0 is slick.