I have total control over my entire domain and its subdomains, and I want to replace the URL displayed in the address bar with a subdomain but not redirect the page.
For example, when I load subdomain.mydomain.com?register
I want the address bar to display register.mydomain.com
without redirecting.
ALL pages and subdomains of mydomain.com
already have document.domain = 'mydomain.com';
as the first thing in the $(window).load(function () {
code of its external .js
file.
I've tried history.pushState("", "", '/');
to strip away anything after the subdomain.mydomain.com
(which works), and I've been able to display something after the /
(which also works), but I can't get the displayed subdomain to change before the /
.
How do I do this? Is it possible at all? If so, does it rely on document.domain
? And if it does, am I executing document.domain
properly??
Should I put
<script type="text/javascript">
document.domain = 'mydomain.com';
</script>
by itself in the <head>
of my HTML files, or will it work just fine being in the $(window).load(function () {
code of its external .js
file?