在设置全新的 Laravel 安装时,我们必须使用domain.com/public 而不是domain.com 来运行它。
我在谷歌上搜索了这个问题,发现这可能是因为 mod_rewrite
未启用。但是,我们在我们的服务器上运行 Plesk,其文档位于 http://download1.parallels.com/Plesk/PP12/12.0/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=74206.htm说:
The mod_rewrite module is enabled by default in Apache that comes with Plesk for Linux. To make use of the functionality, you will need to create an .htaccess file containing the desired rewrite rules - refer to the Apache documentation for more information.
如果我将 public 的内容移到主文件夹中,并将其余内容移到/laravel 文件夹中(只需采用主 index.php 文件),Laravel 工作正常。
但是我想保留原始的文件结构。 有什么建议吗?
最佳答案
只需使用 .htaccess 从/重定向到/public。也许类似于这个
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
关于apache - Plesk-Server 上的 Laravel - 只能通过调用/公共(public)访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36372687/