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: 
If you're using Apache Server your default root directory will probably be `/var/www/html` and the Apache server will look at a file or a folder named `index` like `index.html` or `index.php` to access immediately. What you need to do is:

* Go to the folder you want to be pointed to (`/home/user/folder` in your example) right click on the folder and click 'Make Link' (or whatever is the CLI alternative).
* Now that the link file is created, rename it to be 'index' an then move it to your Apache root folder `/var/www/html`.
* Last important step is to make sure that Apache has the proper permissions to access the files needed (i.e the link we created and named `index` and the `/home/user/folder` directory and the files needed to be accessed within that directory).
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).