I have realized many projects based on webapplications. When you jump into this topic you tend to use XAMPP and there is nothing to say against it. To be honest, I still use this application. It is super easy and very efficient because you do not have to spend too much time with the configuration of your local server. But there is a very common failure many beginners tend to make: they do not use the full power of the tool.
We have to understand that there are two popular ways to address servers. To make it easier to understand it, you have to think of a building that hosts multiple parties. For example: a shopping mall with multiple stores.
To be able to guide the right way there has to be a map with the address and the labels. When we talk about webservers we use the terminology virtual blocks (nginx) or virtual hosts (apache). The configuration of these blocks or hosts tells the server which directory it has to serve when a user requests a host. Within XAMPP this can be done via the "httpd-vhosts.conf"- file. You can find this file in the following subfolders of your XAMPP-installation: "apache\conf\extra".
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "C:/xampp/htdocs/domain.tld" ServerName domain.tld ServerAlias www.domain.tld ErrorLog "logs/domain.tld-error.log" CustomLog "logs/domain.tld-access.log" common </VirtualHost>
This example states that both addresses "domain.tld" and "www.domain.tld" are handled by the server via this entry.
Ok so now we are able to serve different content based on the domain we request. But for now the hostnames are not pointing to our local environment. So we either need to reconfigure our local DNS or the hosts-file of the system. When we use the DNS all of the devices in the network will be manipulated. Otherwise only our single computer will be affected. I always liked to work with both versions of the project (online/productive and local/development) at the same time. This is possible because my online versions always start with www (at least websites). So I can configure the hosts file so that only entries without the www are handled by my local system. Please keep in mind that you may also need to deactivate the redirect to the www if you have already done your SEO.