'Obtaining the URL from address bar with Javascript when using forward with Masking?

I have a domain: landing-domain.com. I would like to forward landing-domain-two.com to landing-domain.com using a forward with masking.

So when users visit landing-domain-two.com they will be redirected to landing-domain.com but the address bar will still show landing-domain-two.com.

What I would like to do is change some things on landing-domain.com using:

window.location.hostname

However, when I use that javascript, it just returns the initial domain name (landing-domain.com) and not the forward with masking domain (landing-domain-two.com).

Is there any way to get the masking URL from the address bar in Javascript?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source