Domain based page

When loading the site for the consumer, I would like to show a specific page based on the domain used to reach the site.

Where would I put the javascript code to do that?

The way I read that, that’s how websites work. Can you give an example so we can understand please.

I can register 2 domains, i.e. Site1. com and Site2. com that point to the same directory and load the same content. I would like to show page1 if the user visited Site1. com and show page2 if the user visited Site2. com.

A javascript can read the document.domain property to see if the user typed “Site1. com” or “Site2. com” into the browser. I can then redirect the browser to the page of interest based on this.

So both domains need to access the same website, you just want them to have different landing pages?

I would suggest… and someone else here may have a better opinion, is you do as much of that server side as possible.

So you could have site 1 go to the usual index.html page and site 2 go to index2.html by default.
You could setup a redirect in your hosting to make that happen.