I'm getting stuck in configuring app.yaml on GAE in order to redirect in PHP code. I'd like to redirect to another HTML page called thanks.html in thanks/thanks.html directory after pushing submit button in index.php. However, it redirects to index.php from index.php With the current settings. I think PHP code don't detect my thanks.html. So I'd like to ask you what point is wrong on my app.yaml and should I use dispatch.yaml?? Thank you so much. Except redirecting, other functions are working fine.
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: "********"
You will need to deploy a front controller to handle all request routing in App Engine. Deploy with the codes below:
index.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');
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.