PHP urlrewrite returns different REQUEST_URI solutions under IIS and apache_PHP tutorial

WBOY
Release: 2016-07-13 10:57:47
Original
1114 people have browsed it

I used to make a function to get the url. I used the Linux system at the time. It turns out that I can use REQUEST_URI, but the method seems to be different in Windows. Today I saw such an article again, and now I will forward it to you. refer to.

When PHP operates on the Windows IIS platform, some things are different from those under Linux Apache.

I encountered a magical problem today, which is to use $URI=$_SERVER["REQUEST_URI"];

What you see under Linux is the static address of urlrewrite /exy/exk/list-3/

The original address returned under windows is /exy/article.php?page=3

At this time, I discovered that there is a method under windows, HTTP_X_REWRITE_URL

This array does not exist in Linux
Therefore, the code is slightly modified to be compatible with both platforms. (It’s really hard to adapt to changing servers)

$URI = $_SERVER["HTTP_X_REWRITE_URL"]; if($URI==null){
The code is as follows
 代码如下 复制代码

$URI = $_SERVER["HTTP_X_REWRITE_URL"];
if($URI==null){
$URI=$_SERVER["REQUEST_URI"];
}
//print_r($_SERVER);
echo $URI;

Copy code

$URI=$_SERVER["REQUEST_URI"]; }

//print_r($_SERVER);

echo $URI; In this way, both platforms can be displayed correctly.
http://www.bkjia.com/PHPjc/632068.htmlwww.bkjia.com
truehttp: //www.bkjia.com/PHPjc/632068.htmlTechArticleI used to make a function to get the url, and I was using the Linux system. It turned out that I could use REQUEST_URI, but The method seems to be different in windows. Today I saw another article like this...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template