1 Reply Latest reply on Oct 23, 2014 8:40 AM by asabban

    How to easily pull the URL.Host out of a URL


      I'd like to create a rule that checks if the URL.Host or the Referer Header matches a list of URL.Hosts.  However, since the Referer Header is a URL, what is an easy way to extract just the URL Host part of the header to compare against the list of URL.Hosts I already have?


      I am using Header.Get("Referer") to get the header.  Thanks for any assistance.

        • 1. Re: How to easily pull the URL.Host out of a URL



          you can do something like this:


          - Store the original URL the user requested:


          User-Defined.MyURL = URL


          - Load the URL from the Referer Header into the "URL" property:


          URL = Header.Get("Referer")


          Now you can use all the URL.* properties and they will work on what is stored in the "URL" property. So "URL.Host" will now return the host that you copied from the Referer header to the "URL" property.


          So you can for example get the host by doing:


          User-Defined.MyRefererHost = URL.Host


          Finally, to tell MWG to connect to the originally requrested URL, restore the URL you previously backed up:


          URL = User-Defined.MyURL