Forum Discussion

SteveEason_3059's avatar
SteveEason_3059
Icon for Nimbostratus rankNimbostratus
Feb 01, 2019

Forwarding to external URL while keeping variables/folders

So we have a situation where our marketing team needs to create various tracking items for our websites and they don't have the know how or access needed to do this on our F5. In the past we've used an external resource at Hubspot to create these for them. So they are creating URLs that look something like this. We are using this as a kind of URL shortener process.

 

 

 

Then these URL's go to Hubspot where they get forwarded over to our main website with additional tags for tracking. Something like:

 

https://www.mainwebsite.com/product/client1?utm_source=client1&utm_medium=print-eob&utm_campaign=client1&utm_content=2019-jan

 

Here is where we have issues. Hubspot cannot host our root domain to manage DNS. So we have to use an external DNS service. We have our corporate DNS hosted with Azure, which doesn't support redirects to a URL. The address we are told by Hubspot to forward traffic, is a URL, like http://hubspotcustomer.A4029.hubspot.com (something like that). So we cannot setup a 301 redirect to an IP address with them.

 

We did setup a www cname on Azure DNS, and forwarded traffic to that prefix to the URL and that appears to work. However, if a visitor goes to http://shorturl.com/client1 (without the leading www) then it strips out the additional folder on the end. (/client1) That then just gets forwarded to the main website from Hubspot.

 

We also tried working with our domain registrar to do a domain wide 301 redirect to the URL, which can be done however when we set that up it didn't work. We contacted their support and they said, oh to do that you would have to upgrade to the advanced DNS service, which will cost $10,000 (not exactly that but a close annually).

 

So now we are back to trying to figure this out on the F5 side of things. If we can create a new VIP for all traffic coming into *.shorturl.com and then either use an irule or policy to forward that over to the Hubspot URL (http://hubspotcustomer.A4029.hubspot.com) while keeping the trailing client information, that might just work.

 

http://www.shorturl.com/client1 -> http://hubspotcustomer.A4029.hubspot.com/client1 -> delivered correctly.

 

Any suggestions on how to accomplish this? I'm unsure how Hubspot handles it on their end, but I just got access to the control panel and I'm researching that next. Thanks in advance!

 

4 Replies

  • Hi Steve,

    I think you would be looking at something like that, although I am not completely certain because I am not sure that I fully understand your post :

    when HTTP_REQUEST {
      switch [string tolower [HTTP::host]] {
        "shorturl.com"  {
          HTTP::respond 301 Location http://www.shorturl.com[HTTP::uri]
        }
        "www.shorturl.com" {
          HTTP::respond 301 Location http://hubspotcustomer.a4029.hubspot.com[HTTP::uri]
        }
      }
    }
    

    So if someone came in using shorturl.com/client1, he/she would be redirected to , and then the next request coming in for would get redirected to http://hubspotcustomer.a4029.hubspot.com/client1. The query string would follow as well if you have one as [HTTP::uri] contains both path and query string.

  • Ok so that makes sense. And if a request comes in with already, would this iRule affect that traffic? Or would we need a rule separate for

     

  • would get redirected to http://hubspotcustomer.a4029.hubspot.com.

     

    A user coming in with shorturl.com would make a request to the Virtual Server (VIP), hit the iRule, get redirected to . The user would make a second request to the Virtual Server, this time for , hit the iRule again and get redirected to hubspotcustomer.a4029.hubspot.com. Then the user would make a third request going to hubspotcustomer.a4029.hubspot.com.

     

    A user coming in with would make a request to the Virtual Server, hit the iRule, get redirected to hubspotcustomer.a4029.hubspot.com. The user would make a second request to hubspotcustomer.a4029.hubspot.com.

     

    This happens transparently for the users by the way, as browsers follow redirections automatically.