Forum Discussion

gh0std0g_79292's avatar
gh0std0g_79292
Icon for Nimbostratus rankNimbostratus
Mar 06, 2013

simple HTTP host replacement... i think? It's not working for me.

I have an internal HTTP sharepoint site, but there are certain DNS names and paths that are mainly for aesthetics and some other things. I'll get to the point.

 

The internal site is 'internal.company.com/index.html' and Sharepoint needs to see this in the host header value. I don't even care about the response so much at this point. But here's what I need:

 

When someone goes to 'applicationA.company.com' I need a URI appended of "/departments/applicationA/index.html" (simple enough)

 

But someone may also receive an email with an embedded link of: 'applicationA.company.com/departments/applicationA/mydoc/me%today....etc...' And I need them to get to that exact document.

 

Here's my iRule:

 

 

when HTTP_REQUEST {

 

if {[HTTP::host] equals "applicationA.company.com"} {

 

HTTP::uri "/departments/applicationA/"

 

}

 

HTTP::header replace Host internal.company.com

 

}

 

 

The above works to a degree. If someone goes to applicationA.company.com, they get to the correct landing spot, which is internal.company.com/departments/applicationA/

 

 

However when someone clicks on a link - applicationA.company.com/departments/applicationA/mydoc/me%today....etc...

 

They get to internal.company.com/departments/applicationA/

 

 

When I add a trailing slash to the host name, as follows, it does the opposite. The hyperlinks bring you straight to the requested document. But if you go to applicationA.company.com only the host header is rewritten, and you land on internal.company.com/index.html.

 

 

when HTTP_REQUEST {

 

if {[HTTP::host] equals "applicationA.company.com/"} {

 

HTTP::uri "/departments/applicationA/"

 

}

 

HTTP::header replace Host internal.company.com

 

}

 

 

 

I imagine this should be simple but it's giving me a lot of grief. Should I be using datagroups?

 

 

Thanks in advance.

 

 

4 Replies

  • can you try this one?

    when HTTP_REQUEST {
       if { ( [HTTP::host] equals "applicationA.company.com" ) and
            ( [HTTP::uri] equals "/" ) } {
          HTTP::uri "/departments/applicationA/"
       } 
       HTTP::header replace Host internal.company.com
    }
    
  • You could also look at Alternate Access Mappings in Sharepoint to do this natively on SP without an iRule:

     

     

    How Do I: Configure an Alternate Access Mapping in SharePoint 2010?

     

    http://technet.microsoft.com/en-us/sharepoint/ff679917.aspx

     

     

    Alternate Access Mapping Basics in SharePoint 2013 (This post is in its entirety valid for SharePoint 2010 as well)

     

    http://blog.blksthl.com/2012/12/03/a-guide-to-alternate-access-mappings-basics-in-sharepoint-2013/

     

     

    Aaron
  • Thanks guys...

     

    Re: Nitass -- That iRule worked and I knew I was missing something simple like that, so thanks. I guess the challenge is that there are multiple references to 'internal.company.com'; i.e. appA.company.com, appB and appC etc... I want to replace headers on some, but keep headers on others and this is due to the way Sharepoint zones have been set up. So if I go that route, I'll either build off your iRule or I guess creating a datagroup would accomplish the same?

     

     

    Are datagroups more efficient than performing the same logic in an iRule? At least in this case?

     

     

    Re: Arron... The problem with Sharepoint alternate access mappings is that I'm limited to 5 mappings... 1 per zone I think? I'm not the Sharepoint person.
  • Are datagroups more efficient than performing the same logic in an iRule? At least in this case?i believe so especially if you have several number of references. additionally, it is much easier to add/remove/change data in data group rather than in irule.