首先,考虑到这个答案只是为了让它工作,我不确定这可能对安全性产生任何影响,因为每个文件夹都在您网站的公共部分。
其次,我只是使用准系统 laravel 安装进行了尝试,所以我不确定这是否会在以后的开发中产生影响(我的猜测不是,但你永远不知道)。
1)复制public
根laravel文件夹(这是您的子文件夹)中文件夹的所有内容
2)您现在可以删除空public
文件夹
3) 编辑index.php
和更改
// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require '../paths.php';
到
// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require './paths.php';
4)编辑paths.php并更改
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = 'public';
到
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = '.';
5) 编辑 laravel 文件夹中的 .htaccess 文件,使其不再重定向到 public
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>