各个WEB软件判断请求URL
IIS7 + Rewrite Module -> $_SERVER['HTTP_X_ORIGINAL_URL']IIS6 + ISAPI Rewite -> $_SERVER['HTTP_X_REWRITE_URL’]
Apache2 -> $_SERVER['REQUEST_URI’] 或 $_SERVER['REDIRECT_URL']
nginx -> $_SERVER['REQUEST_URI’]
因此得出的结果是,只要判断
$_SERVER['HTTP_X_REWRITE_URL'] 和$_SERVER['REQUEST_URI']的区别
IIS+PHP不支持$_SERVER['REQUEST_URI'],并且php4.4.0不支持 $_SERVER['REQUEST_URI'],php5.2.5则增加了支持;$_SERVER['REQUEST_URI']常用来获当前URL。例如:http://www.sjzphp.com/index.php?p=3
$_SERVER['REQUEST_URI']获得的就是/index.php?p=3这部分。
$_SERVER["HTTP_X_REWRITE_URL"]则在IIS下获得的是当前URL,在apache下的值为空
举例说明在IIS和APACHE环境下获取URL
当前URL:http://www.sjzphp.com/IIS环境下:
$_SERVER['REQUEST_URI'] = /index.php
$_SERVER["HTTP_X_REWRITE_URL"] =/
apache环境下:
$_SERVER['REQUEST_URI'] = /
$_SERVER["HTTP_X_REWRITE_URL"] =”
IIS环境下:
$_SERVER['REQUEST_URI'] = /index.php
$_SERVER["HTTP_X_REWRITE_URL"] =/index.php
apache环境下:
$_SERVER['REQUEST_URI'] = /index.php
$_SERVER["HTTP_X_REWRITE_URL"] =”
而我需要的就是判断当前URL是否包含/index.php,由此可见,IIS环境下首先域名重定向用$_SERVER["HTTP_X_REWRITE_URL"]代替$_SERVER['REQUEST_URI'],apache环境则相反。青锋建站,提供专业的高品质网站制作服务,包括网站建设,SEO,网络营销,PHP开发,网站建设知名品牌,全国接单,为企业构建强有力的营销平台。
转载请注明来源网址:青锋建站-http://www.sjzphp.com/webdis/http_x_rewrite_url_1073.html