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).
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/)