1

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.

  • 2
    you'd probably want to show the HTML you have, and ask this question on stackoverflow, as this is not at all raspberry pi specific - and there's a LOT more HTML experts on stackoverflow than here :p – Jaromanda X May 14 at 0:18
1

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 :-)

| improve this answer | |
  • <Directory /data> - Ordinarily, it would the target path (that is outside the DocumentRoot) of the Alias (eg. /home/pi/sites) that you would need to enable access to. You would expect the source path to already be accessible. – MrWhite Jul 4 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.