Question: I have a URL to be mapped, on my Ubuntu 16.04 machine, to a local folder.

E.g. I need `https://domainxxx.xxx` to point to `/home/user/folder`.

My specific need is to include `domainxxx.xxx/file.js` not as the real 'file.js' on the remote server, but as `/home/user/folder/file.js` which is on my machine.

I've read this is not possible with an entry in `/etc/hosts`. How can I do this?

Answer: 
First you need to install LAMP stack or just web server as: [Apache](https://httpd.apache.org/), [Lighttpd](https://www.lighttpd.net/) or [Nginx](https://nginx.org/). Then you must configure your web server and enable [HTTPS](https://en.wikipedia.org/wiki/HTTPS), if you really need **s**ecure connection, not just [**HTTP**](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol).

---

Here you are few HOW-TOs about Apache2:

* How-to [install LAMP](https://askubuntu.com/q/34/566421), see also [the official documentation](https://help.ubuntu.com/community/ApacheMySQLPHP).
* How-to [configure Apache2 Virtual Hosts](https://askubuntu.com/a/811416/566421).
* How-to [open port 80/443 (HTTP/HTTPS) into the firewall](https://help.ubuntu.com/lts/serverguide/firewall.html).
* How-to [enable a free certificate from Let's Encrypt](https://askubuntu.com/a/900433/566421).
* How-to [increase your web server's security](https://askubuntu.com/a/922144/566421).
LAMP (Linux Apache MySQL and PHP) is the best way as it runs a server on your local machine. 
I wrote a how to install and set up on my website [how to install LAMP on Ubuntu](https://iancroasdell.wordpress.com/installing-lamp-on-ubuntu/)