Search code examples
apacheserverwebserverapache2relative-path

Apache2 relative paths not working


Good Morning, I am currently setting up and apache2 server on my raspberry pi. My index.html file is in the directory /var/www/html and the file is loading fine when I go to the IP address. However, the images located in /var/www/html/img are not loading. The html is like this: <img alt="image1" src="img/picture1.png">. When I right click on the alternative image icon, and select open image in new tab, I get:

You don't have permission to access /img/picture1.png on this server.
Server unable to read htaccess file, denying access to be safe

How can I prevent this and make the user able to access the image?

Many thanks,


Solution

  • Try

    chmod -R 755 /img/
    

    this will set the permission for all files in the folder readable and executable for all, and also writable by the owner.

    The output will be in the form

    -rwxr-xr-x    1 root     root             0 Apr  5 12:38 picture1.jpg