【问题标题】:Accesing laravel public folder using root index file使用根索引文件访问 laravel 公用文件夹
【发布时间】:2019-07-31 06:01:49
【问题描述】:

Laravel 版本 - 5.8。

我必须在不使用php artisan serve 命令的情况下在共享主机上部署我的 Laravel 项目。因此,出于这个原因,我已将我的根文件 server.php 文件重命名为 index.php。

如果我将文件 server.php 重命名为 index.php 会有什么安全后果或错误吗?

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    您不需要将 server.php 重命名为 index.php。只需将 Public/index.php 移动到文件夹的根目录,并在移动后更改 index.php 内的必要路径。它肯定会起作用。

    【讨论】:

      【解决方案2】:

      如果您使用cPanel,您可以将webroot 更改为public,非常简单,不需要重命名server.php。如果不是,您可以使用.htaccess 将所有请求重定向到public 文件夹,如下所示:

      # public_html/.htaccess
      
      <IfModule mod_rewrite.c>
          <IfModule mod_negotiation.c>
              Options -MultiViews
          </IfModule>
      
          RewriteEngine On
      
          # Redirect All Requests To The Subfolder
          RewriteRule ^ /public
      
      </IfModule>
      

      【讨论】:

        猜你喜欢
        • 2013-06-03
        • 2017-01-23
        • 2017-06-27
        • 2020-12-24
        • 2020-04-01
        • 2017-03-23
        • 1970-01-01
        • 2021-05-30
        • 1970-01-01
        相关资源
        最近更新 更多