DEV Community

Discussion on: How to link Custom Domain with URL ?

Collapse
memahesh profile image
Medam Mahesh Author

Hi,
Can you give me more context using this example?
Suppose I own service like wix.com and I have a customer 'A' who owns a domain 'xyz.com'. Customer 'A' builds his website through my service and now he wants his website to be rendered when someone browses 'xyz.com'. How can I achieve that through a coding interface?

P.S.: I want to code it in such a way that Customer 'A' can point his website to the domain 'xyz.com' without anybody's help.

Collapse
richardj profile image
R☭

Well, you can't fully achieve that through a coding interface, i think. So let me draw you up how i have done it for some of my domains.

So i've built a website and that website is running on a certain with an IP. You can browse to that website by typing in the IP, and voila you see the website. But i want users to be able to visit my website through my-domain.com. A few things need to happen:

  1. We need to tell whoever owns the domain, that when a user goes to my-domain.com that we actually want to connect with a certain IP address. This is what the DNS records are for. They tell you what it should actually looking at when a user sees my-domain.com and will be something like: A record 192.168.0.1

  2. optional: When you have a single server with a lot of websites on it we need to differentiate what website we want to show the user. Because how would we know which website to serve when we point to 192.168.0.1? This is where the web server comes into place. In there you define configuration files which basically say: listen to this port, if the domain the request is coming from is my-domain.com load the following folders in the webserver.

So to go back. If you own a service like wix.com AND the user will buy their domain through you, you could do all the steps yourself programmatically (i think, there could be some caveat), if the domain name is bought with a different provider, the user needs to change the settings through their provider to point that domain name to the service (like wix.com). And in most cases the user has to put in that information themselves.