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

Gurdip_Sira_175's avatar
Gurdip_Sira_175
Icon for Nimbostratus rankNimbostratus
Oct 28, 2015

iRule for redirect - multiple sites to check

Hi

 

I am looking to implement an iRule on F5 to redirect sites to a new location.

 

However, I need to able to check at the SharePoint subsite level eg:

 

https://corpsites.domain.com/it/dr

 

And then have a switch statement for multiple source sites to redirect to multiple new sites.

 

Could anyone advise on what an iRule like this would look like?

 

Thanks

 

8 Replies

  • Can you provide a little more detail on what you're trying to accomplish? Input URL and expected redirect location.
  • Hi Brad

     

    The application is SharePoint 2010/2013 (to redirect from) and 2013 to redirect to.

     

    SharePoint URLs for site collections and sites typically look like this:

     

    https://groups.companyname.com/it/SitePages/Home.aspx

     

    So that would be the landing page of a site to redirect from, but users may go direct to a specific page (like /Contacts.aspx), so I need some sort of wildcard to redirect from any page in the site:

     

    I can just redirect to the homepage of the site (which is the same url structure).

     

    So the pseudo code would be:

     

    If (URL is any page under site url) { Redirect to "url")

     

    So something like https://groups.companyname.com/it/SitePages/*.aspx to indicate any page on the source site.

     

    Thanks

     

  • Is the 'from' hostname (domain) relevant? Or only the path? The following code ;-

     

    if {[HTTP::path] starts_with "/it/Sitepages" } {
        HTTP::respond "https://[HTTP::host]/[URI::basename [HTTP::uri]]"
    }

    would redirect from;-

     

    https://groups.companyname.com/it/SitePages/Home.aspx

    to;-

     

    https://groups.companyname.com/Home.aspx
    • Gurdip_Sira_160's avatar
      Gurdip_Sira_160
      Icon for Nimbostratus rankNimbostratus
      Hi, That still redirects to the same site/domain name. The "to" should be a completely different domain ie groups2.companyname.com/it/SitePages/Home.aspx How would the syntax look if this is a multiple if/else statement?
  • Sounds pretty straight forward. Give this a try:

    when HTTP_REQUEST {
        if {[HTTP::path] starts_with "/it/Sitepages" } {
            HTTP::respond 301 noserver "https://groups2.companyname.com[HTTP::uri]"
        }
    }
    
    • Gurdip_Sira_160's avatar
      Gurdip_Sira_160
      Icon for Nimbostratus rankNimbostratus
      Thanks! I will try this tomorrow but it looks like what I need, from a psuedo code and syntax perspective.
  • Sounds pretty straight forward. Give this a try:

    when HTTP_REQUEST {
        if {[HTTP::path] starts_with "/it/Sitepages" } {
            HTTP::respond 301 noserver "https://groups2.companyname.com[HTTP::uri]"
        }
    }
    
    • Gurdip_Sira_160's avatar
      Gurdip_Sira_160
      Icon for Nimbostratus rankNimbostratus
      Thanks! I will try this tomorrow but it looks like what I need, from a psuedo code and syntax perspective.