重定向到非ASCII域名后的HTTP响应代码 [英] HTTP response code after redirect to non-ascii domain name

查看:107
本文介绍了重定向到非ASCII域名后的HTTP响应代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取将域重定向到非ASCII域的所有标头?

How can I get all headers for domain redirecting to non-ASCII domain?

相关问题

域www.sendevinci.co.il重定向到非ASCII域www.מגשי-אירוח.co.il.

The domain www.sendevinci.co.il redirecting to non-ASCII domain www.מגשי-אירוח.co.il.

我的代码是:

$url = 'http://www.sendevinci.co.il';

$options['http'] = array(
	'method' => "HEAD",
        'ignore_errors' => 1,
        'header' =>
 	       	"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" .
        	"Accept-Language: en-US,en;q=0.8\r\n".
                "Keep-Alive: timeout=3, max=10\r\n",
                "Connection: keep-alive",
	'user_agent' => self::get_user_agent_string($user_agent),
        "timeout" => 3
);

$context = stream_context_create($options);

$body = file_get_contents($url, NULL, $context);

print_r($http_response_header);

结果是:

Array
(
    [0] => HTTP/1.1 301 Moved Permanently
    [1] => Server: nginx
    [2] => Date: Thu, 07 Jun 2018 13:07:30 GMT
    [3] => Content-Type: text/html; charset=UTF-8
    [4] => Connection: close
    [5] => X-Powered-By: PHP/7.2.6
    [6] => Location: https://www.מגשי-אירוח.co.il
    [7] => X-Powered-By: PleskLin
)

该数组还应包含200个状态,但不包括200个状态.

The array should include 200 status as well, but it not.

该代码对于将ascii名称域重定向到ascii名称域的效果很好.

The code works fine for ascii-name domains redirecting to ascii-name domains.

感谢您的帮助!

推荐答案

实际上,file_get_contents仅适用于ascii域名.因此,没有简单的解决方案来获取所有http标头...

Actually, file_get_contents works ONLY with ascii domain names. So there are no simple solution to get all http headers...

这篇关于重定向到非ASCII域名后的HTTP响应代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆