I am trying to create a localhost website that has multiple links to redirect to other .html files on the raspberry pi. These other .html files and websites are located in a folder located at /home/pi/sites. The website root is located at /var/www/html . My current index.html file for the localhost website has a hyperlink which redirects to the .htm file of another website. When I try to open the hyperlink on the localhost website, I get an error 404. If I run the html file not as a local host, but through the web browser, the hyperlink works. Please help me setup the localhost.
1 Answer
Not a great idea as security settings can get in a right mix as the web pages (and services) run under the user www-data and not the user pi.
If you determined to do this (and it's really not a good idea for security of the website) then Apache lets you do it with the alias module (mod_alias). Once enabled, you can set something like the following:
Alias /data /home/pi/sites
<Directory /data>
Order allow,deny
Allow from all
</Directory>
Then http://192.168.1.12/data/sitepage.html points to the file /home/pi/sites/sitepage.html
Details of this module can be found on the Apache site But please note this can be messed up with redirects and care needs to be taken as to order (see lower part of the linked page). Very sure this will trip WordPerfect or even WordPress (sorry about that) web sites up :-)
-
<Directory /data>
- Ordinarily, it would the target path (that is outside the DocumentRoot) of theAlias
(eg./home/pi/sites
) that you would need to enable access to. You would expect the source path to already be accessible.– MrWhiteCommented Jul 4, 2020 at 1:40