简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM