url-rewritingurl-maskingdomain-masking

I need to hide the full URL extensions of my website


I would like to mask the URL extensions of my website.

If the name of my website is: mywebsite. I have various content pages on my site such as: contentpage1.html or contentpage2.html

Normally, when a content page is opened, the browser address bar displays:

mywebsite.com/contentpage1.html or mywebsite.com/contentpage1.html

Is there a way to mask that, so no matter what pages are being viewed on my site, ONLY the root URL mywebsite.com and nothing more is always shown in the address bar?


Solution

  • This is simplier as you think. This is my case, just try this:

    (function hideMyURL() {
        var re = new RegExp(/^.*\//);
        window.history.pushState("object or string", "Title", re.exec(window.location.href));
    })();
    

    Is it this what you're looking for?