aタグ内aタグをクリックした時のリファラとアクセスログ

hogehoge.com/start.html
<html><head></head><body><a href="proxy.html"><a href="referer.cgi">AAAAAA</a></a></body></html>


hogehoge.com/proxy.html
<html><head></head><body>test</body></html>


hogehoge.com/referer.cgi
#!/usr/bin/perl

print "Content-type: text/html\n";
print "\n";
print "$ENV{'HTTP_REFERER'}";



start.htmlから「AAAAAA」をクリックしてreferer.cgiに飛んでみる。

referer.cgiのブラウザ表示
http://hogehoge.com/start.html


httpのヘッダたち
Request URL:http://hogehoge.com/referer.cgi
Request Method:GET
Status Code:200 OK

▼Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:Shift_JIS,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:ja,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Cookie:●●●
Host:hogehoge.com
Referer:http://hogehoge.com/start.html
User-Agent:Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2

▼Response Headersview source
Connection:Keep-Alive
Content-Type:text/html
Date:Sun, 04 Dec 2011 16:25:53 GMT
Keep-Alive:timeout=5, max=18
Server:Apache/1.3.42 (Unix) mod_ssl/2.8.31 OpenSSL/0.9.8e
Transfer-Encoding:chunked



ちゃんとReferer:http://hogehoge.com/start.htmlになってる。


アクセスログはどうなってるのっと。
%more access_log_20111205 | grep --line-buffered 2011:01 | grep proxy.html

hogehoge.com IPアドレス - - [05/Dec/2011:01:25:53 +0900] "GET /proxy.html HTTP/1.1" 200 46 "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2"

proxy.htmlもGETしてて200が返ってる。

へぇー。


プロのWeb屋さんとか鯖屋さん的には当たり前なんだろうけど,個人的に考えたことすらなかったのでメモ。
当然っちゃ当然の結果。


どうでもいいけどリファラーの正しい綴りってReferrerなのね。
HTTP_REFERERだけど,単語としてはReferrer。
7へぇー。

コメント

匿名 さんのコメント…
> HTTP_REFERERだけど,単語としてはReferrer

Chromeの文字化けで試行錯誤中でした。
リンク元の文字コードを使用してしまうので、refferre情報を削除したくて右往左往していました。
ここから、PHP環境変数「$_SERVER['HTTP_REFERER']」にいきつけました。
ありがとうございました。

このブログの人気の投稿

ソフトバンク光BBユニットのセキュリティと、Wi-Fiルーターのファイアウォールをちゃんと確認した

Twitter=>discord連携の際に、複数行のテキストを取り出す場合はIFTTTじゃなくてZapierを使うといい

懐かしのミニ四駆たちがでてきました。