【问题标题】:Laravel version 5.7 root show index of pageLaravel 5.7 版根显示页面索引
【发布时间】:2018-12-11 03:16:55
【问题描述】:

最近我开始使用 Laravel,我在本地开发了一个网站,效果很好,但是当我将它部署到 DigitalOcean 中的 droplet 时,根目录显示一个 index Of 页面。

Screen Capture is here

当我导航到公用文件夹时,它显示 500 错误。

我尝试包含几个不同的 .htaccess,但这并不能解决问题。而我当前的 .htaccess 在下面

DirectoryIndex index.php

选项 - 多视图

RewriteEngine On

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]

RewriteRule .? %{ENV:BASE}/index.php [L]

“Options -MultiViews”这一行实际上也是 .htaccess 代码的一部分。

谁能帮我解决这个问题?

提前谢谢你。

【问题讨论】:

    标签: laravel laravel-5.7


    【解决方案1】:

    查看更多here

    在服务器配置文件中,AllowOverride 是设置为 All 还是 None?如果将其设置为 none,则所有 .htaccess 更改都将被忽略。

    <Directory /var/www/YOURAPP/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    

    【讨论】:

    • 服务器500错误问题已经修复,500错误之后还有一些问题也在修复中。但是,目前我仍然遇到一个奇怪的问题。当我访问我的域的根目录时,浏览器显示 403 禁止消息。但是当我访问 domain/public 时,它会显示正确的内容,这意味着我错过了一些设置,但是我应该更改什么?
    • 你能编辑 apache conf 文件吗?在该文件中有一些注释掉的代码,您可以像this 一样编辑它们,但将路径更改为您的应用程序路径。
    【解决方案2】:

    别忘了生成密钥...

    php artisan key:generate
    

    https://laravel.com/docs/5.7/installation

    【讨论】:

      猜你喜欢
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      • 2016-03-25
      • 2021-09-26
      • 1970-01-01
      相关资源
      最近更新 更多