Back to feed

Domain Manager

? Deleted user · 7 months ago · 3 replies · 389

Is there a way to set up a domain and use it as primary and whenever someone goes to the original subdomain that it forces the new domain name?

3 replies
Cory · 7 months ago

You can accomplish this with a piece of JavaScript in the head section, for example:

<script>
const defaultDomain = 'sparkpromotion.forumspark.net';
const customDomain = 'google.com';

if (window.location.hostname === defaultDomain) {
    window.location.href = 'https://' + customDomain + window.location.pathname + window.location.search;
}
</script>
?
Deleted user OP · 7 months ago

Would be easier to have it as default especially if this platform allows custom domains.

Does that code do a wildcard redirect?

Cedric · 7 months ago

Yeah, it's annoying that happens. I'll look into this if I can fix that. I'll keep you updated.

Create a free account to join the conversation.
Sign up free
ForumSpark © 2023 - 2026 · ForumSpark.net · Terms