php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64272 IIS7开启rewrite时Yaf_Request无法正确获取请求URI
Submitted: 2013-02-22 08:25 UTC Modified: 2013-10-15 11:54 UTC
From: wynn dot chen dot cn at gmail dot com Assigned:
Status: No Feedback Package: yaf (PECL)
PHP Version: 5.4.12 OS: Windows
Private report: No CVE-ID: None
 [2013-02-22 08:25 UTC] wynn dot chen dot cn at gmail dot com
Description:
------------
yaf2.2.9,IIS7 + Url Rewrite Module 2(最新版本)

plugin中尝试输出 $request->getRequestUri() 查看永远是 string(0) ""

使用的rewrite规则等价于Apache下的
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

web.config对应代码为:
<rule name="master" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php" logRewrittenUrl="true" />
</rule>

根据微软的文档(http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#Preserving_Original_URL),原始请求url保留在$_SERVER['HTTP_X_ORIGINAL_URL'],实测此项值正常。


看源代码似乎用了和zend framework类似的判定方案(/request/http.c 53行起)。实测$_SERVER中并没有“HTTP_X_REWRITE_URL”这一项,只有“HTTP_X_ORIGINAL_URL”,另外“IIS_WasUrlRewritten”这项永远是null,微软的文档内也未见相关说明。


Test script:
---------------
例:访问
http://www.example.com/subdirectory/st/action/

在plugin中:
var_dump($request->getRequestUri());




Expected result:
----------------
 string(24) "/subdirectory/st/action/"

Actual result:
--------------
string(0) ""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-22 09:36 UTC] laruence@php.net
我不太了解IIS, 不过你可以查看下是不是因为PATH_INFO为""引起的, Yaf_Request的requri优先使用
PATH_INFO.
 [2013-02-22 09:36 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2013-02-26 02:57 UTC] wynn dot chen dot cn at gmail dot com
感谢您的快速回应。

并没有$_SERVER['PATH_INFO']这一项。

在我的开发环境下,访问:
http://www.mytest.com/path/path2/path3/abc/
得到的$_SERVER实际信息如下:

//var_dump($_SERVER);
array(92) {
  ["PROCESSOR_ARCHITEW6432"]=>
  string(5) "AMD64"
  ["_FCGI_X_PIPE_"]=>
  string(53) "\\.\pipe\IISFCGI-754ba21e-a52b-4e85-8573-8e4a36086c81"
  ["ALLUSERSPROFILE"]=>
  string(14) "C:\ProgramData"
  ["APPDATA"]=>
  string(56) "C:\Windows\system32\config\systemprofile\AppData\Roaming"
  ["APP_POOL_CONFIG"]=>
  string(39) "C:\inetpub\temp\apppools\dpc\dpc.config"
  ["APP_POOL_ID"]=>
  string(3) "dpc"
  ["CommonProgramFiles"]=>
  string(35) "C:\Program Files (x86)\Common Files"
  ["CommonProgramFiles(x86)"]=>
  string(35) "C:\Program Files (x86)\Common Files"
  ["CommonProgramW6432"]=>
  string(29) "C:\Program Files\Common Files"
  ["COMPUTERNAME"]=>
  string(7) "OFFICE-PC"
  ["ComSpec"]=>
  string(27) "C:\Windows\system32\cmd.exe"
  ["FP_NO_HOST_CHECK"]=>
  string(2) "NO"
  ["LOCALAPPDATA"]=>
  string(54) "C:\Windows\system32\config\systemprofile\AppData\Local"
  ["NUMBER_OF_PROCESSORS"]=>
  string(1) "4"
  ["OS"]=>
  string(10) "Windows_NT"
  ["Path"]=>
  string(295) "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\php;C:\Program Files\TortoiseSVN\bin;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ImageMagick-6.8.1-Q16;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\lua\bin;"
  ["PATHEXT"]=>
  string(53) ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
  ["PROCESSOR_ARCHITECTURE"]=>
  string(3) "x86"
  ["PROCESSOR_IDENTIFIER"]=>
  string(50) "Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
  ["PROCESSOR_LEVEL"]=>
  string(1) "6"
  ["PROCESSOR_REVISION"]=>
  string(4) "2a07"
  ["ProgramData"]=>
  string(14) "C:\ProgramData"
  ["ProgramFiles"]=>
  string(22) "C:\Program Files (x86)"
  ["ProgramFiles(x86)"]=>
  string(22) "C:\Program Files (x86)"
  ["ProgramW6432"]=>
  string(16) "C:\Program Files"
  ["PSModulePath"]=>
  string(51) "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\"
  ["PUBLIC"]=>
  string(15) "C:\Users\Public"
  ["SystemDrive"]=>
  string(2) "C:"
  ["SystemRoot"]=>
  string(10) "C:\Windows"
  ["TEMP"]=>
  string(15) "C:\Windows\TEMP"
  ["TMP"]=>
  string(15) "C:\Windows\TEMP"
  ["USERDOMAIN"]=>
  string(9) "WORKGROUP"
  ["USERNAME"]=>
  string(8) "OFFICE-PC$"
  ["USERPROFILE"]=>
  string(40) "C:\Windows\system32\config\systemprofile"
  ["windir"]=>
  string(10) "C:\Windows"
  ["ORIG_PATH_INFO"]=>
  string(10) "/index.php"
  ["URL"]=>
  string(10) "/index.php"
  ["SERVER_SOFTWARE"]=>
  string(17) "Microsoft-IIS/7.5"
  ["SERVER_PROTOCOL"]=>
  string(8) "HTTP/1.1"
  ["SERVER_PORT_SECURE"]=>
  string(1) "0"
  ["SERVER_PORT"]=>
  string(2) "80"
  ["SERVER_NAME"]=>
  string(14) "www.mytest.com"
  ["SCRIPT_NAME"]=>
  string(10) "/index.php"
  ["SCRIPT_FILENAME"]=>
  string(23) "D:\dpc\public\index.php"
  ["REQUEST_URI"]=>
  string(22) "/path/path2/path3/abc/"
  ["REQUEST_METHOD"]=>
  string(3) "GET"
  ["REMOTE_USER"]=>
  string(0) ""
  ["REMOTE_PORT"]=>
  string(5) "63841"
  ["REMOTE_HOST"]=>
  string(14) "192.168.100.99"
  ["REMOTE_ADDR"]=>
  string(14) "192.168.100.99"
  ["QUERY_STRING"]=>
  string(0) ""
  ["PATH_TRANSLATED"]=>
  string(23) "D:\dpc\public\index.php"
  ["LOGON_USER"]=>
  string(0) ""
  ["LOCAL_ADDR"]=>
  string(14) "192.168.100.99"
  ["INSTANCE_META_PATH"]=>
  string(11) "/LM/W3SVC/3"
  ["INSTANCE_NAME"]=>
  string(3) "DPC"
  ["INSTANCE_ID"]=>
  string(1) "3"
  ["HTTPS_SERVER_SUBJECT"]=>
  string(0) ""
  ["HTTPS_SERVER_ISSUER"]=>
  string(0) ""
  ["HTTPS_SECRETKEYSIZE"]=>
  string(0) ""
  ["HTTPS_KEYSIZE"]=>
  string(0) ""
  ["HTTPS"]=>
  string(3) "off"
  ["GATEWAY_INTERFACE"]=>
  string(7) "CGI/1.1"
  ["DOCUMENT_ROOT"]=>
  string(13) "D:\dpc\public"
  ["CONTENT_TYPE"]=>
  string(0) ""
  ["CONTENT_LENGTH"]=>
  string(1) "0"
  ["CERT_SUBJECT"]=>
  string(0) ""
  ["CERT_SERIALNUMBER"]=>
  string(0) ""
  ["CERT_ISSUER"]=>
  string(0) ""
  ["CERT_FLAGS"]=>
  string(0) ""
  ["CERT_COOKIE"]=>
  string(0) ""
  ["AUTH_USER"]=>
  string(0) ""
  ["AUTH_PASSWORD"]=>
  string(0) ""
  ["AUTH_TYPE"]=>
  string(0) ""
  ["APPL_PHYSICAL_PATH"]=>
  string(14) "D:\dpc\public\"
  ["APPL_MD_PATH"]=>
  string(16) "/LM/W3SVC/3/ROOT"
  ["IIS_UrlRewriteModule"]=>
  string(10) "7.1.0871.0"
  ["UNENCODED_URL"]=>
  string(22) "/path/path2/path3/abc/"
  ["IIS_WasUrlRewritten"]=>
  string(1) "1"
  ["HTTP_X_ORIGINAL_URL"]=>
  string(22) "/path/path2/path3/abc/"
  ["HTTP_DNT"]=>
  string(1) "1"
  ["HTTP_USER_AGENT"]=>
  string(72) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0"
  ["HTTP_HOST"]=>
  string(14) "www.mytest.com"
  ["HTTP_ACCEPT_LANGUAGE"]=>
  string(35) "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"
  ["HTTP_ACCEPT_ENCODING"]=>
  string(13) "gzip, deflate"
  ["HTTP_ACCEPT"]=>
  string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  ["HTTP_CONTENT_LENGTH"]=>
  string(1) "0"
  ["HTTP_CONNECTION"]=>
  string(10) "keep-alive"
  ["FCGI_ROLE"]=>
  string(9) "RESPONDER"
  ["PHP_SELF"]=>
  string(10) "/index.php"
  ["REQUEST_TIME_FLOAT"]=>
  float(1361847112.2165)
  ["REQUEST_TIME"]=>
  int(1361847112)
}

希望以上信息能有帮助。
 [2013-10-15 11:54 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 00:01:31 2024 UTC