Within Apache you could use the alias option in the configuration file for the site as per this answer I gave a while ago but in this case there are two better options as you want the whole site to move.
Note the rest of this answer assumes your external drive is mounted to /mnt/external and the directory 'website' is the new root directory (i.e. holding the index page) so you would access the contents of the index page with
cat /mnt/external/website/index.html
The first this to note is that any directory structure you are creating should have its security set correctly to limit possible hacks and to give www-data access (often read-only to none data files). Normally I would do this by making the owner and group www-data with
cd /mnt/external/website
chown -R www-data:www-data .
Note this will cut the Pi user off from these directories. You may want to make changes using sudo
or make Pi a member of the www-data group with:
sudo usermod -a -G www-data pi
Read only can then be done using:
chmod -R 0444 /mnt/external/website
Other values can be set depending on your needs (and blanket use of 0444 breaks many a web site)...
Once you have security set correctly, then there are two ways of simply moving the root:
May LEAST favourite way to move the whole root is to edit the document root declaration (DocumentRoot) in:
/etc/apache2/sites-enabled/000-default
/etc/apache/apache2.conf
e.g.
DocumentRoot "/mnt/external/website"
This impacts every site by default so I find it normally better to define the root location within the site definition files and then enable them with a2ensite. Virtual hosts can have the root defined in their definition file along the lines of:
<VirtualHost *:80>
DocumentRoot "/mnt/external/website"
ServerName www.example.co.uk
</VirtualHost>
Full details of remapping URLs to file locations is here on the Apache site.
After any of these changes you will need to restart Apache with
sudo systemctl restart apache2
without this the changes are not recognised.
Normally, my sites live in directories that match the site URL (inc .org / .co.uk etc) and the definition files are the full site name as well. This helps me keep track when using virtual sites but does not save typing!
but neither of them will serve content that's not in the root folder
- you're doing it wrong ... in nginx it's as simple asroot /what/ever/path/you/want
in aserver
config