twitter経由でリンクを踏んだ時、リンク先にampがあればモバイル端末からのアクセスの場合はそちらに飛ばす。
これ(通常のURI)をtwitterに貼ると https://t.co/PgzG5H7J14?amp=1 みたいなURIへのリンクになる。
curl $ curl https://t.co/PgzG5H7J14?amp=1 -iHTTP/2 301cache-control: private,max-age=300content-length: 0date: Fri, 25 Dec 2020 10:23:37 GMTexpires: Fri, 25 Dec 2020 10:28:37 GMTlocation: https://nna774.net/server: tsa_mset-cookie: muc=32fba616-6508-492b-9d41-0dd3b15471b4; Max-Age=63072000; Expires=Sun, 25 Dec 2022 10:23:37 GMT; Domain=t.co; Secure; SameSite=Nonestrict-transport-security: max-age=0vary: Originx-connection-hash: 26f9d1480d0013233499211e1b68a718x-response-time: 106
普通にアクセスすると元のURIに301で飛ぶ。
curl-ip$ 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/15E148Safari/604.1'HTTP/2 200amp: 1cache-control: private,max-age=300content-length: 318content-type: text/html; charset=utf-8date: Fri, 25 Dec 2020 10:25:30 GMTexpires: Fri, 25 Dec 2020 10:30:30 GMTreferer: https://nna774.net/server: tsa_mset-cookie: muc=812c7580-15cc-4fda-bf2c-864baddd9779; Max-Age=63072000; Expires=Sun, 25 Dec 2022 10:25:30 GMT; Domain=t.co; Securestrict-transport-security: max-age=0vary: Originx-connection-hash: 105f7aaaddcffaccc07974f1aa0f0a41x-response-time: 113x-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$ 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 200cache-control: private,max-age=300content-length: 212content-type: text/html; charset=utf-8date: Fri, 25 Dec 2020 10:24:24 GMTexpires: Fri, 25 Dec 2020 10:29:24 GMTserver: tsa_mset-cookie: muc=071ca055-8dab-4c66-b4f6-20a7a4c6be0a; Max-Age=63072000; Expires=Sun, 25 Dec 2022 10:24:24 GMT; Domain=t.co; Securestrict-transport-security: max-age=0vary: Originx-connection-hash: d130fc1871ae7f251944429e86929b6ax-response-time: 110x-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のものが帰ってきた。