3

I asked this before. The question was marked Duplicate. Unfortunately a newbie like me did not know it was a duplicate.

The ‘answers’ I did not understand. I am sorry to ask dumb questions. I deleted the question and ask again. More simple and shorter.

I want to start a ‘web site’ located on a USB stick. I started with the OS that came with my Raspberry Pi and then:

sudo apt-get update

sudo apt-get install apache2 -y

cd /var/www/html

sudo chown pi: index.html

leafpad index.htm

Replace everything in index.html with: enter image description here

I double-clicked index.html and YES there was my web site everything worked. I hurried to my router and forwarded port 80 to my Pi. Got my phone out, switched off WiFi and in Chrome I typed the outside IP of my router. The almost empty page said Redirect. I can live with the fact that it skipped the meta line.

I am stuck here. If I double click the index.html then Chromium knows what to do. If I type localhost on the Pi in Chromium then I think Apache kicks in and I am stuck like I was before with my phone.

Tried a lot - umount, mount, fdisk, but nothing. Made www-data member of a lot, even of root. No change. Tried to make Apache run as root. The default picture on my Pi desktop is a road. It leads to nowhere.

Or is there somebody that can explain in a view lines what to do? Please easy, Absolute beginner, first time user. If it can’t be done in a simple way, I will forget about it. So far I can’t deal with complicated answers.

regards Neef

1
  • As a side note, avoid hardcoding absolute URLs in your web pages. If you didn't, your problem wouldn't have even existed. Commented Apr 26, 2017 at 8:14

4 Answers 4

2

You are confusing file system paths and URLs.

The link points to a file on the Pi's file system, but your phone or PC does not have that particular file system mounted. (The local browser works because, of course, the Pi has access to the Pi's file system.)

For a file to be served by a web server (Apache), it needs to be found in the server's "web root" path, which is set in the server config file. The index.html file is, but the start.htm is not. Clicking on the "Redirect" link, just tells the browser to open a local file, which does not exist.

Try making a (filesystem) link to it:

cd /var/www/html
ln -s /media/pi/F2DA-650F/fb/start.htm

Then it should be accessible as http://[hostname-or-ip]/start.htm

1

That href you gave links to a local location, not accessable from the outside. You link to your local files. You should put the file in your www folder, because these are accessible from the outside.

So for example

www/index.html < this is your html file

www/media/start.html < this is the file you are linking to

And now you should make the href like this

href="media/start.html"

This should fix your problem.

Or just edit the apache settings to see the usb folder as the www folder. Just make sure you auto mount the USB to a fixed location.

0

When you double-click index.html you are starting a web browser and telling it to open that file through the file system (disk). Therefore, even if it works, it is not going through Apache. It is at least testing your doctored-up index.html and your stuff on flash drive.

When you use your phone, it is a different browser and it is going through Apache, so it seems the combination is not liking our setup, at least the redirected page.

If I were you, I would try modifying the documentroot of Apache to point to your flash drive, as described in this article. See it is described in the ery first question: "I ended up figuring it out. Some suggested I change the httpd.conf file, but I ended up finding a file in /etc/apache2/sites-available/default and changed the root directory from /var/www to /home/myusername/projects_folder and that worked.".

See where that guy changed the default site's root to /home/myusername/projects_folder ? That's what you need to do with your flash drive.

You might also have to rename start.htm on the flash drive to index.html, or duplicate it under the name index.html. That is because web browsers automatically go looking for index.html.

0

Tried everything, nothing worked. Problem solved. Inserted a 64 Gb SD card. 20 minutes later I was 'On air' I Still think the problem with the USB drive is connected on how you mount the drive. Bye!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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