Aizaz Shahid
Aizaz Shahid

Reputation: 23

How can I protect path of my public folder in Laravel

The problem is that I have placed all my images and files on my site in the public folder. Now, in order to prevent leeching of files, I want to restrict the access to the public folder by URL. I know, I should have put those files in storage but, if I do that now, I would have to change paths in the whole site. So, is there a way to protect my public folder?

Upvotes: 0

Views: 709

Answers (1)

Michael Hillcox
Michael Hillcox

Reputation: 48

You could use Apache or Nginx to restrict the access to public and use a custom route to serve your public data but that wouldn't be ideal. Logically the best way to solve this is to convert everything into Laravel's storage system and write a micro script to convert any links from the public directory to the storage serving route.

Although, a small code example would help me give you the best advice for your issue.

Upvotes: 1

Related Questions