apache - Plesk-Server 上的 Laravel - 只能通过调用/公共(public)访问

标签 apache .htaccess laravel mod-rewrite plesk

在设置全新的 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/

相关文章:

.htaccess 将 "/"重定向到非 "/"是 500 内部服务器错误

php - api 端点未在 Sanctum 上进行 CSRF token 验证 - CSRF token 不匹配

apache - 如何配置 Apache 作为 j2ee 服务器的代理(负载均衡器)?

apache - mod_rewrite 制作短网址

php - .htaccess 在 Windows 上工作,但在 ubuntu 中的 apache2 上不起作用

php - Laravel 5 数据库连接问题

mysql - Eloquent where() 语句

php - 映射 CIFS 共享上的 chown 不起作用

java - 似乎无法让从我的 Android 应用程序发送的 http 获取参数显示在我的 PHP 页面上

html - 使用 htaccess 处理 DDos?