Query_string and Request_uri differences in $_server functions

Source: Internet
Author: User
Tags vcard

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

1,http://localhost/aaa/ (open index.php in AAA)
Results:
$_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 (with inquiry)
Results:
$_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
Results:
$_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";

by Example:
$_server["Query_string"] gets the query statement, in the instance, gets the following value
$_server["Request_uri"] gets the value after http://localhost, including/
$_server["Script_name"] gets the path to the current script, such as: index.php
$_server["Php_self"] The file name of the script that is currently executing   difference between $_server[' Request_uri ' and $_server[' Http_x_rewrite_url '] http://www.hujuntao.com/web/php/difference-between-server-request-uri-and-server-http_x_rewrite_url.html
 

wordpress implementation of non-first-domain (non-WWW) jump by 301 redirects it would have been a simple thing, Because the difference between $_server[' Http_x_rewrite_url ' and $_server[' Request_uri ' was not clarified, the problem of cyclic redirection was caused.
Now to specifically study $_server[' Http_x_rewrite_url The difference between '] and $_server[' Request_uri ']
The first thing to correct is that iis+php does not support $_server[' Request_uri ']
No, the issue of PHP version is not supported, php4.4.0 does not support $_server[' Request_uri '],php5.2.5 adds support;

$_server[' Request_uri ') commonly used to obtain the current URL
Span style= "font-family: ' Microsoft Yahei '; font-size:18px; " > example: http://www.hujuntao.com/index.php?p=3
$_server[' Request_uri '] got/index.php?p=3 this part.

$_server["Http_x_rewrite_url"] The current URL is obtained under IIS, and the value under Apache is null

example:
current url:http://www.hujuntao.com/
IIS environment:
$_server[' request_uri '] =/ index.php

$_server[' request_uri ' =/
$_server[" Http_x_rewrite_url "] ="

Current url:http://www.hujuntao.com/index.php
In the IIS environment:
$_server[' Request_uri '] =/index.php
$_server["Http_x_rewrite_url"] =/index.php
Apache Environment:
$_server[' Request_uri '] =/index.php
$_server["Http_x_rewrite_url"] = "

Query_string and Request_uri differences in $_server functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.