cancel
Showing results for 
Search instead for 
Did you mean: 
phlrnnr
Level 9

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

Jump to solution

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 Solution

Accepted Solutions
asabban
Level 17

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

Jump to solution

Hello,

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

Best,

Andre

1 Reply
asabban
Level 17

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

Jump to solution

Hello,

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

Best,

Andre