I’ve made a website using Laravel, but I’d like to make it redirect if a user tries to visit a public storage directory (not an image/file). Currently it displays a 403 error).
For example, an image might be hosted at "mywebsite.com/storage/uploads/Image1.jpg", if a user removes the "Image1.jpg" part and tries to visit "mywebsite.com/storage/uploads/" or "mywebsite.com/storage/", a 403 error is shown.
I would prefer if the user was redirected to the home page in this case. How can I accomplish this?
2
Answers
You can try adding this in the web/routes.php
use the code below
});