首页 文章

将Laravel项目上载到服务器后图像无法正常工作

提问于
浏览
0

我已将我的laravel项目上传到共享主机上,我的图片将无效 .

我在根目录中添加了 .htaccess ,除了图像之外,每个东西都工作 . 我的 .htaccess 文件在下面 .

RewriteEngine On
RewriteBase /
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

我的图片链接是 mydomain.com/storage/facilities/May2017/BYKdbdIQCezQ6Gsh05EK.jpg

并且它显示您无权访问此服务器上的 /public/storage/facilities/May2017/BYKdbdIQCezQ6Gsh05EK.jpg .403 ERROR此符号链接错误?我没有ssh访问权限,所以有没有办法链接存储文件夹?

2 回答

  • 2

    这是一个简单的解决方案,您可以使用cron job创建符号链接,您需要做的就是 .

    1)php(工匠的绝对路径)存储:链接

    像php / home /(yourusername)/ public_html / artisan storage:link

    要么

    2)ln -s / home /(yourusername)/ public_html / storage / app / public / / home /(yourusername)/ public_html / public

    转到公用文件夹并将public重命名为storage .

  • 1

    两件事情:

    1)我建议您将图像放在资源文件夹中

    2)众所周知,Laravel不喜欢您访问Storage文件夹 . 如果需要,您可以更改它的权限,但我强烈建议您在决定将其设置为之前知道自己在做什么 .

相关问题