例如,你有 example.com(裸域,A型) www.example.com(ghs.googlehosted.com,输入CNAME) 并且您希望301将www.example.com重定向到example.com。以下是redirect.php
> <?
> $direct_redirects = array("www.example.com" => "http://example.com",);
>
> $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
> $redirect_url = $direct_redirects[$path];
if(!is_null($redirect_url)) {
> header("HTTP/1.1 301 Moved Permanently");
> header("Location: $redirect_url"); }
的app.yaml
handlers:
- url: /.*
script: redirect.php
- url: /(.*)
static_files: index.html
upload: index.html
它不起作用。
你怎么做你用PHP重定向GAE?
答案 0 :(得分:0)
我在重定向网址时遇到了同样的问题。 假设您已经购买了example.com,并且已将其与谷歌云连接,但您想将301重定向到www.example.com ...那么就这样了 转到您购买example.com(godaddy / namecheap或任何其他)的帐户页面 然后在“DNS设置”页面中添加(或编辑已经添加的)“URL重定向”记录,并将所需的目标URL添加到“www.example.com”,其中添加字段具有选项“屏蔽”,“未屏蔽”&amp; “301(永久移动)”,选择301(永久移动)选项,几分钟后301重定向将起作用。