For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Puli's avatar
Puli
Icon for Nimbostratus rankNimbostratus
Nov 18, 2009

migrate apache redirects to iRule

Hi ,

 

need hep in migrating our apache redirects to an iRule.

 

We have about 600 redirects setup in apache.

 

Am looking for a generic iRule to handle all 600.

 

The apache redirect vary based on the host.

 

For example:

 

Scenario 1: Redirect to a particular page

 

 

ServerName abc.foo.com

 

RedirectMatch 301 ^/(.*) http://newsite.foo.com/us/abc/index.html

 

 

 

We have about 400 of these with differrent ServerNames

 

 

Scenario 2 : Rewrite Rules

 

 

 

ServerName abc.foo.com

 

RewriteEngine On

 

RewriteRule ^/support/docs(.*) http://newsite.foo.com/adc/support/docs [R=301]

 

RewriteRule ^/support(.*) http://newsite.foo.com/adc/support [R=301]

 

RewriteRule ^/(.*) http://newsite.foo.com/adc [R=301]

 

 

 

have about 100 differrent ServerNmaes of these type

 

 

Scenario 3 : RedirectMatch

 

 

 

ServerName abc.foo.com

 

RedirectMatch 301 ^/(.+)$ http://newsite.foo.com/adc/en/$1

 

RedirectMatch 301 ^/servers/(.*)$ http://newsite.foo.com/adc/servers/$1

 

RedirectMatch 301 ^/(.*)$ http://newsite.foo.com/adc

 

 

have about 100 differrent ServerNmaes of these type

 

 

All our apache redirects fall into one of above scenarios.

 

Can you please help me write a generic iRule to handle all of them.

 

thanks. appreciate you help

 

Venu.

 

 

2 Replies

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Venu,

     

     

    Try searching this forum for mod_rewrite to find a few examples. If you try something and get stuck, add logging to the iRule (Click here), reply here with what you're testing, what the client sees and logs from /var/log/ltm.

     

     

    mod_rewrite to iRule assistance

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=62642

     

     

    rewrite rule

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=29745

     

     

    Performaing complex Apache like rewrites

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=19947

     

     

    Aaron
  • Puli's avatar
    Puli
    Icon for Nimbostratus rankNimbostratus
    Thanks for the info Aaron.

     

    I will keep this post updated as ia work through.