HTTP_REFERER的工作方式(转)

下列情况是从浏览器的地址栏正常取得Request.ServerVariables("HTTP_REFERER")的:
1.直接用<a href>
2.用Submit或<input type=image>提交的表单(POST or GET)
3.使用Jscript提交的表单(POST or GET)

下面我们再看看Request.ServerVariables("HTTP_REFERER")不能正常取值的情况:
1.从收藏夹链接
2.单击'主页'或者自定义的地址
3.利用Jscript的location.href or location.replace()
4.在浏览器直接输入地址
5.<%Response.Redirect%>
6.<%Response.AddHeader%>或<meta http-equiv=refresh>转向
7.用XML加载地址

显然,Request.ServerVariables("HTTP_REFERER")在多数情况下是不能正常工作的,下面我们看一个例子:
ref.asp
<%
response.write "You came from: " & request.servervariables("http_referer")
%>

ref.htm
<%
Response.AddHeader "Refresh", "10;URL=ref.asp"
%> 

<meta http-equiv='refresh' content='10;URL=ref.asp'> 

<form method=GET action=ref.asp name=getform> 
<input type=submit value=' Go there (GET) >> '> 
<input type=image style='cursor:hand'> 
</form><p> 
看看上面的代码会得到什么的结果.
<form method=POST action=ref.asp name=postform> 
<input type=submit value=' Go there (POST) >> '> 
<input type=image style='cursor:hand'> 
</form><p> 

<a href='ref.asp'>直接链接<p> 

<a href='#' οnclick='window.location.href="ref.asp";return false;'>javascript location</a> 

<a href='#'οnclick='window.location.replace("ref.asp");return false;'>javascript replace</a> 

<a href='#' οnclick='document.getform.submit();return false;'>javascript GET</a> 

<a href='#' οnclick='document.postform.submit();return false;'>javascript POST </a>
user root; #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } rtmp_auto_push on; #RTMP 服务 rtmp{ server{ listen 9090; application live { live on; #开启实时 record all; record_unique on; record_path "/usr/local/rtmp_video"; #视频缓存路径 record_suffix -%Y-%m-%d-%H_%M_%S.flv; hls on; #开启hls hls_path /usr/local/m3u8File; #hls的ts切片存放路径 hls_fragment 2s; #本地切长度 hls_playlist_length 6s; #HLS播放列表长度 } } } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; sendfile on; #tcp_nopush on; keepalive_timeout 65; server { listen 9092; server_name localhost; location / { root /usr/local/rtmp_video; #指定哪目录作为Http服务器根目录 autoindex on; #设置允许列出整目录 autoindex_exact_size off; #默认为on,显示文件的准确大小单位是bytes,改为off,显示文件大概大小,单位KB/MB/GB autoindex_localtime on; #默认为off ,显示的文件时间为GMT时间,改为on后显示文件的时间为文件的服务器时间。 charset utf-8; #防止文件乱码显示,如果用utf-8还是乱码可以改成,gbk试一下 } } server { listen 9091; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location /live_hls{ types{ #m3u8 type设置 application/vnd.apple.mpegurl m3u8; #ts分片文件设置 video/mp2t ts; } #指向访问m3u8文件目录 alias /usr/local/m3u8File; add_header Cache-Control no-cache; #禁止缓存 } location /control{ rtmp_control all; } location /stat{ rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl{ root ./nginx-rtmp-module-master; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } }
最新发布
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值