twitter経由でリンクを踏んだ時、リンク先にampがあればモバイル端末からのアクセスの場合はそちらに飛ばす。

twitter経由でリンクを踏んだ時、リンク先にampがあればモバイル端末からのアクセスの場合はそちらに飛ばす。

これ(通常のURI)をtwitterに貼ると https://t.co/PgzG5H7J14?amp=1 みたいなURIへのリンクになる。
curl
Copied!
$ curl https://t.co/PgzG5H7J14?amp=1 -i
HTTP/2 301
cache-control: private,max-age=300
content-length: 0
date: Fri, 25 Dec 2020 10:23:37 GMT
expires: Fri, 25 Dec 2020 10:28:37 GMT
location: https://nna774.net/
server: tsa_m
set-cookie: muc=32fba616-6508-492b-9d41-0dd3b15471b4; Max-Age=63072000; Expires=Sun, 25 Dec 2022 10:23:37 GMT; Domain=t.co; Secure; SameSite=None
strict-transport-security: max-age=0
vary: Origin
x-connection-hash: 26f9d1480d0013233499211e1b68a718
x-response-time: 106

普通にアクセスすると元のURIに301で飛ぶ。
curl-ip
Copied!
$ curl https://t.co/PgzG5H7J14?amp=1 -i -H 'user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148
Safari/604.1'
HTTP/2 200
amp: 1
cache-control: private,max-age=300
content-length: 318
content-type: text/html; charset=utf-8
date: Fri, 25 Dec 2020 10:25:30 GMT
expires: Fri, 25 Dec 2020 10:30:30 GMT
referer: https://nna774.net/
server: tsa_m
set-cookie: muc=812c7580-15cc-4fda-bf2c-864baddd9779; Max-Age=63072000; Expires=Sun, 25 Dec 2022 10:25:30 GMT; Domain=t.co; Secure
strict-transport-security: max-age=0
vary: Origin
x-connection-hash: 105f7aaaddcffaccc07974f1aa0f0a41
x-response-time: 113
x-xss-protection: 0

<head><noscript><META http-equiv="refresh" content="0;URL=https://nna774.net/amp/#click=https://t.co/PgzG5H7J14"></noscript><title>https://nna774.net/amp/#click=https://t.co/PgzG5H7J14</title></head><script>window.opener = null; location.replace("https:\/\/nna774.net\/amp\/#click=https:\/\/t.co\/PgzG5H7J14")</script>
一方、iPhoneっぽいUAを適当に貼ってアクセスするとamp verに飛ぶようなmeta tagやjsの入ったhtmlが200で帰ってきて、amp verのuriへと誘導される。
へ〜 おもしろ という感じのメモ

curl-ip-amp-0
Copied!
$ curl https://t.co/PgzG5H7J14?amp=0 -i -H 'user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
HTTP/2 200
cache-control: private,max-age=300
content-length: 212
content-type: text/html; charset=utf-8
date: Fri, 25 Dec 2020 10:24:24 GMT
expires: Fri, 25 Dec 2020 10:29:24 GMT
server: tsa_m
set-cookie: muc=071ca055-8dab-4c66-b4f6-20a7a4c6be0a; Max-Age=63072000; Expires=Sun, 25 Dec 2022 10:24:24 GMT; Domain=t.co; Secure
strict-transport-security: max-age=0
vary: Origin
x-connection-hash: d130fc1871ae7f251944429e86929b6a
x-response-time: 110
x-xss-protection: 0

<head><noscript><META http-equiv="refresh" content="0;URL=https://nna774.net/"></noscript><title>https://nna774.net/</title></head><script>window.opener = null; location.replace("https:\/\/nna774.net\/")</script>
ちなみに amp=0 にパラメータをすると通常のURIに飛ばされるようなcontentのものが帰ってきた。

Powered by Helpfeel