【问题标题】:Image not working after uploading Laravel project to server将 Laravel 项目上传到服务器后图像无法正常工作
【发布时间】:2017-06-30 00:00:37
【问题描述】:

我已在共享主机上上传了我的 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 错误 这是符号链接错误吗?我没有 ssh 访问权限,有没有办法链接存储文件夹?

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    这是简单的解决方案 您可以使用 cron 作业创建符号链接,您需要做的是。

    1) php (artisan 的绝对路径) storage:link

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

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

    转到公共文件夹并将公共重命名为存储。

    【讨论】:

      【解决方案2】:

      两件事:

      1) 我建议您将图片放在资产文件夹中

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

      【讨论】:

        猜你喜欢
        • 2017-07-16
        • 2017-12-09
        • 2018-01-29
        • 1970-01-01
        • 2013-05-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多