为什么Twitter的t.co出现在Referer中,但是没有URL缩短器呢?

时间:2016-07-07 06:53:45

标签: http url-rewriting url-routing url-redirection http-referer

我在Referer文件中注意到t.co/oPQO7Xdz一大串access_log个链接,但没有其他网址缩短版显示出来。为什么呢?

1 个答案:

答案 0 :(得分:2)

网址缩短器永远不会显示,因为HTTP中的HTTP 301 Moved Permanently et al重定向并非旨在影响Referer HTTP Request Header(显然,即使标头为空白,也可能是因为它是'否则会导致行为不一致。

但是,如果Twitter发现它认为是受欢迎的桌面版或移动版t.co,则不会使用User-Agent服务发布301 Moved Permanently重定向。由于重定向因此在HTTP堆栈之外完成,因此后续全新HTTP请求中的Referer字段将被组合以包括负责重定向的先前HTML页面,从而导致{{1} }条目出现在t.co

access_log

将此与其他情况进行比较(这是大多数其他URL缩短程序重定向的唯一方法,这将保留当HTTP请求首次访问浏览器的HTTP堆栈时出现的% curl -v -A"iPhone;" t.co/oPQO7Xdz * About to connect() to t.co port 80 (#0) * Trying 104.244.42.5... * connected * Connected to t.co (104.244.42.5) port 80 (#0) > GET /oPQO7Xdz HTTP/1.1 > User-Agent: iPhone; > Host: t.co > Accept: */* > < HTTP/1.1 200 OK < cache-control: private,max-age=300 < content-length: 258 < content-security-policy: referrer always; < content-type: text/html; charset=utf-8 < date: Thu, 07 Jul 2016 05:24:16 GMT < expires: Thu, 07 Jul 2016 05:29:16 GMT < server: tsa_o < set-cookie: muc=1f43e292-e319-4818-ba81-f12d16e5b629; Expires=Tue, 19 Jun 2018 05:24:16 UTC; Domain=t.co < x-connection-hash: 0dc5a2a6a7e83ac2d7fb207eb0cedf84 < x-response-time: 115 < x-xss-protection: 1; mode=block < * Connection #0 to host t.co left intact <head><meta name="referrer" content="always"><noscript><META http-equiv="refresh" content="0;URL=http://mdoc.su/n/curl"></noscript><title>http://mdoc.su/n/curl</title></head><script>window.opener = null; location.replace("http:\/\/mdoc.su\/n\/curl")</script>* Closing connection #0 :< / p>

Referer