例如,您有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上做301重定向?
发布于 2017-11-03 23:16:12
我在重定向URL时遇到了同样的问题。假设你已经购买了example.com,且你已经将它与谷歌云连接,但是你想对www.example.com...So进行301次重定向,去到你购买了example.com账户页面(godaddy/namecheap或任何其他),然后在"DNS设置“页面中添加(或编辑已经添加的)记录,用于"URL重定向”,并将所需的目标URL添加到"www.example.com“中,选择301 (永久移动)选项,几分钟后301重定向将起作用。
https://stackoverflow.com/questions/36155635
复制相似问题