我被困在 GAE 上配置 app.yaml 以便在 PHP 代码中重定向。在按下 index.php 中的提交按钮后,我想重定向到另一个名为Thanks.html 的 HTML 页面,在Thanks/thanks.html 目录中。但是,它使用当前设置从 index.php 重定向到 index.php。我认为 PHP 代码没有检测到我的Thanks.html。所以我想问你我的 app.yaml 有什么问题,我应该使用 dispatch.yaml 吗?非常感谢。除了重定向,其他功能都正常。
index.php(only the part of redirect to thanks.html)
header("Location: ./thanks/thanks.html");
exit();
app.yaml
runtime: php72
handlers:
- url: /(.*\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: .*
script: auto
http_headers:
- url: /thanks
static_dir: /thanks
env_variables:
SENDGRID_API_KEY: "*********"
DEVELOPER_EMAIL: "********"
您需要部署一个前端控制器来处理 App Engine 中的所有请求路由。使用以下代码进行部署:
索引.php :
<?php
header("Location: ./thanks/thanks.html");
exit();
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
case '/':
require 'index.php';
break;
case 'thanks/thanks.html':
require 'thanks.html';
break;
default:
http_response_code(404);
exit('Not Found');
}
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句