php - 使用 https 找不到 Laravel 路由

标签 php http https laravel-5.2

我在任何路由之上的 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/

相关文章:

php - 如何改善此MySQL查询?

php文件路径/文件扩展名未保存到sql中的数据库

ruby-on-rails - API 的 URL 设计

javascript - 从(邪恶的)feedly 导出 "saved for later"

java - 在 Java EE 中实现 HTTPS

php - PostgreSQL PHP - 使用第二个表的值作为 Excel/CSV 导出中第一个表的值的列标题和列描述

php - mysql表导入不起作用?

http - 从 Windows Phone 应用程序捕获传出 HTTP 请求

python - 从 Web 服务器产生类似文件的响应是如何工作的?

java - Https 使用本地原始文件中的证书进行 android studio