猿问

使用根索引文件访问laravel公共文件夹

Laravel 版本 - 5.8。

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

如果我将文件server.php重命名为index.php会不会有任何安全后果或错误?


白衣非少年
浏览 205回答 2
2回答

长风秋雁

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

aluckdog

如果您使用 cPanel,您可以将 webroot 更改为public非常简单的不需要重命名server.php. 如果没有,您可以使用.htaccess将所有请求重定向到这样的public文件夹:# public_html/.htaccess<IfModule mod_rewrite.c>&nbsp; &nbsp; <IfModule mod_negotiation.c>&nbsp; &nbsp; &nbsp; &nbsp; Options -MultiViews&nbsp; &nbsp; </IfModule>&nbsp; &nbsp; RewriteEngine On&nbsp; &nbsp; # Redirect All Requests To The Subfolder&nbsp; &nbsp; RewriteRule ^ /public</IfModule>
随时随地看视频慕课网APP
我要回答