I got stuck in configuring app.yaml on GAE again. I have already solved similar problem as like last post Last post . now I need to change the directory of thanks.html and I changed code and deployed again but it keeps showing index.php after redirect with the URL.domain/thanks.html ←my app seems to detect redirect url to thanks.html that I set on my code but shows index.php. I have followed GCP documentation but it was not deployed as I expected. If there is any mistake in my code, anyone teach me how to revise?? Thank you so much.
index.php(the only part of redirect to thanks.html)
header("Location: thanks.html");
exit();
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
case '/':
require 'index.php';
break;
case './thanks.html':
require 'thanks.html';
break;
default:
http_response_code(404);
exit('Not Found');
} catch (Exception $e) {
syslog(LOG_ERR, 'Exception: '. $e->getMessage());
}
runtime: php72
entrypoint: serve index.php
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
- url: /
static_files: thanks.html
upload: thanks.html
env_variables:
SENDGRID_API_KEY: "*****"
DEVELOPER_EMAIL: "*****"
I solved this problem with code below but I had already tried same code in several times but this time it worked fine. I'm always really confused with deploying in GAE.
imndex.php
try {
$response = $sendgrid->send($email);
header("Location: ./thanks.html");
exit();
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
case '/':
require 'index.php';
break;
case './thanks.html':;
require './thanks.html';
break;
default:
http_response_code(404);
exit('Not Found');
}
}
app.yaml
- url: /thanks.html
static_files: thanks.html
upload: thanks.html
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.