我有一个核心php网站,这是我当前对app.yaml的配置
runtime: php72
handlers:
# Serve a directory as a static resource.
- url: /assets
static_dir: assets
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /ckeditor
static_dir: ckeditor
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
# add all script entries like this
- url: /login.php
script: auto
# Serve your app through a front controller at index.php or public/index.php.
- url: .*
script: auto
此配置的问题在于,它会不断地重定向(302)到登录页面一次..并最终显示错误太多重定向。
我想念什么?
GAE日志:
2019-01-18 17:10:07 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:10:10 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:10:13 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:10:16 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:10:19 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:10:22 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:10:25 default[20190118t223420] "GET /login.php HTTP/1.1" 302
2019-01-18 17:32:26 default[20190118t225141] "GET / HTTP/1.1" 302
2019-01-18 17:32:26 default[20190118t225141] nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /tmp/google-config/nginx.conf:3
2019-01-18 17:32:30 default[20190118t225141] "GET /login.php HTTP/1.1" 302
2019-01-18 17:32:33 default[20190118t225141] "GET /login.php HTTP/1.1" 302
2019-01-18 17:54:59 default[20190118t230733] "GET / HTTP/1.1" 302
2019-01-18 17:55:00 default[20190118t230733] nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /tmp/google-config/nginx.conf:3
2019-01-18 17:55:02 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 17:55:05 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 17:55:07 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 17:55:09 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 17:55:11 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 18:17:29 default[20190118t230733] "GET / HTTP/1.1" 302
2019-01-18 18:17:32 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 18:17:35 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 18:17:37 default[20190118t230733] "GET /login.php HTTP/1.1" 302
2019-01-18 18:17:40 default[20190118t230733] "GET /login.php HTTP/1.1" 302
答案 0 :(得分:3)
事实证明,对于标准环境,php72不直接支持脚本执行。一切都需要通过自定义的FrontController。因此,我创建了一个FrontController,它基本上可以处理所有路由。以下是我放入index.php中的代码。它将处理所有指定的路线。
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
case '/':
require 'login.php';
break;
case '/product.php';
require 'product.php';
break;
default:
break;
}
您可以在此处找到自定义FrontController和不同框架的php72示例。 https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/appengine/php72
感谢大家的辛勤工作。希望这可以帮助像我这样迷失的灵魂。
答案 1 :(得分:0)
动态:
switch (@parse_url($_SERVER['REQUEST_URI'])['path'])
{
case @parse_url($_SERVER['REQUEST_URI'])['path']:
$name_url_path = substr(@parse_url($_SERVER['REQUEST_URI'])['path'],1);
$name_url_path = empty($name_url_path)?'home_page.php':$name_url_path;
$name_url_path = ($name_url_path == 'index.php')?'home_page.php':$name_url_path;
require $name_url_path;
break;
default:
break;
}