I know how to configure a local web server using xampp on windows ... I enter my alias and target in the hosts file (c: \ windows \ system32 \ drivers \ etc \ hosts), and then add the corresponding entry to my configuration file apache vhosts. Thus, provided that my web server is listening on port 80, I can for example map example.comto my local web server.
I always entered the fully qualified domain name (for example, example.com) in my hosts file, and any requests for that name would be directed to localhost.
Now I was wondering if there is a way to redirect example.com only to a specific port (e.g. example.com:8080) to the local web server and leave example.com (on the default port 80), so it will still go to my live work website.
As far as I understand, this may not be possible using only the hosts file (I tried to add port: 8080 to my domain names - it didn’t work, -)) ...
I really know little about this topic, so any ideas, ideas, links, reading materials, tools are welcome.
Edit: Arnout's answer answers the question I asked above, but does not solve my actual problem. Redirecting example.com:8080 to localhost: 80 really works, and if I go to example.com, it loads the first page of my local version, but all the links on this page, of course, are not aware of the port number and therefore point to the production version ... The actual solution to my problem seems to be to bite into a sour apple and fix my application (after Rob's suggestion) and remove all hard-coded URLs so that it works in any domain ...
source
share