我在任何路由之上的 routes.php 中定义了一个简单的路由:
Route::get('/test', function () {
echo 'hello';
});
它在通过 http 访问时工作,但它给出:
The requested URL /test was not found on this server.
当我尝试通过 https 访问时。
我在互联网上搜索了很多,但找不到任何解决方案。
我的主页同时加载了 http 和 https,但其他路由不起作用。我需要一些额外的配置吗?
编辑:
.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
请指导我。
谢谢。
最佳答案
更新
.env
文件中的APP_URL
,使其以https://
而不是http 开头://
:APP_URL=https://yourserver.com
将此添加到您的 SSL Apache 配置(在 Ubuntu 上:
default-ssl.conf
):
<Directory /var/www/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
allow from all
</Directory>
关于php - 使用 https 找不到 Laravel 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36760124/