1

Related to this question Why isn't my deployed Laravel 8 application finding images in the storage directory through a symbolic link?.

I am using Laravel to build an application and after deployment I set up a symbolic link to access my public storage. However, when I try to access these files I get a console error that looks like this,

test.jpg:1 GET http://website.com/storage/imgs/test.jpg 403 (Forbidden).

I imagine the reason I am getting the 403 error is because I can't follow symbolic links on SiteGround.

The permission for the symbolic link is 777, for the imgs directory it's 755, and for the image it's 644.
Every answer I have seen has been talking about changing the apache config and I am not sure how to do that on SiteGround unless I just need to create my own?
I had to create my own .htaccess file to change those settings on SiteGround. If so what file would I need to make, where would I put the file, and what would I write in it to allow it to follow the symbolic link if this is the case?

For all I know that's not even why it's not working so any other insight on what might be going on would be greatly appreciated!

blue pine
  • 472
  • 6
  • 17
ParkMoss
  • 11
  • 6
  • Are you able to access the image directly from a browser with that URL? – Drewster Sep 17 '21 at 02:21
  • Negative. When I do that I get a 403 error as well. – ParkMoss Sep 17 '21 at 02:44
  • 2
    Probably a good thing, makes it easier to debug by taking it out of your code. Can you access anything else in that directory, or any other directory e.g. just `/imgs`? – Drewster Sep 17 '21 at 03:18
  • I can't. I've tried accessing the storage/imgs and just the storage and I get a 403 on both of them. I even get a 403 error if I try accessing something I know doesn't exist in one of the directories like storage/imgs/fake_image.jpg. I don't know if the later means anything but I would have expected a 404. – ParkMoss Sep 17 '21 at 03:43
  • It probably means that the issue is on the directory rather than the file. It can't access the dir to see if the file exists or not. – Drewster Sep 17 '21 at 04:59
  • I agree. The symbolic link is the storage directory and I think Site Ground can't access it because it's a symbolic link but that's just my guess. – ParkMoss Sep 17 '21 at 05:17
  • The option `FollowSymLinks`, or better yet `SymLinksIfOwnerMatch`, must be set for Apache to allow access to symlinked files. https://httpd.apache.org/docs/2.4/mod/core.html#options – CBroe Sep 17 '21 at 06:42
  • According to the documentation `FollowSymLinks` is set as the default. And regarding changing it how would I do so? There is no file to do so on SiteGround so would I just create one? And where should it be located? In the root directory, public directory, or somewhere else? – ParkMoss Sep 17 '21 at 07:33
  • It fixed itself somehow. I don't think I did anything that changed it. I left it alone because I was frustrated and it works now. My best guess is just something like the server restarts at a certain time at night or something and that fixed it. – ParkMoss Sep 17 '21 at 09:03
  • That's frustrating! But at least it works now and you can concentrate on other stuff! – Drewster Sep 18 '21 at 05:35

0 Answers0