首页 > 解决方案 > NGINX 强制斜线 (GAE)

问题描述

我正在尝试将所有 URL 路由到 Google App Engine(nginx 服务器)中的尾部斜杠

我有一个 Angular-Laravel 5.0 应用程序。默认情况下,我将所有请求路由到位于public/app/目录中的 index.php,因此我有以下规则

这就是我的nginx-app.conf样子

location / {
  index index.php index.html index.html index.js, index.shtml;
  try_files $uri $uri/ /index.php?$query_string;
}

这就是我的app.yaml样子

runtime: php
env: flex

runtime_config:
  document_root: public

这就是我所拥有的app/Http/routes.php

Route::get('/', function () {
    return redirect('/app/');
});

我的问题是

当我通过 URL 访问我的网站时,https://project-id.appspot.com/app/它会将我重定向到,https://project-id.appspot.com/app/#/access/signin但如果我尝试使用

它正在将我重定向到http://project-id.appspot.com:8080/app/ https://project-id.appspot.com/app/

我对此有谷歌并找到了这个答案,但我不知道如何将它与我现有的规则一起使用。

如果有人可以指导我,我将不胜感激。

请注意:我是 nginx 服务器的新手

提前致谢。

标签: google-app-enginenginxlaravel-5url-rewritinggoogle-cloud-platform

解决方案


推荐阅读