$_GET
變量在URL中顯示爲空www.abc.com/ec/basket.php?product_id=1
。
這是非常令人驚訝的,因爲$_GET
確實在同一臺服務器上具有相同URL的不同域上顯示值。當然,代碼是原始域的副本。
我很困惑,爲什麼會發生這種情況。即使代碼的第一行顯示爲空白$_GET
。
當我在頁面的第一行做了print_r($_SERVER)
,我得到以下回應。前兩個值是令人驚訝的。
Array
(
[REDIRECT_REDIRECT_REQUEST_METHOD] => GET
[REDIRECT_REDIRECT_STATUS] => 404
[REDIRECT_STATUS] => 404
[HTTP_HOST] => www.abc.com
[HTTP_CONNECTION] => keep-alive
[HTTP_CACHE_CONTROL] => max-age=0
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.27 (KHTML, like Gecko) Chrome/12.0.712.0 Safari/534.27
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch
[HTTP_ACCEPT_LANGUAGE] => en-GB,en-US;q=0.8,en;q=0.6
[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.3
[HTTP_COOKIE] => [various values]
[PATH] => /sbin:/usr/sbin:/bin:/usr/bin
[SERVER_SIGNATURE] => Apache/2.2.3 (Red Hat) Server at www.abc.com Port 80
[SERVER_SOFTWARE] => Apache/2.2.3 (Red Hat)
[SERVER_NAME] => www.abc.com
[SERVER_ADDR] => [IP address]
[SERVER_PORT] => 80
[REMOTE_ADDR] => [IP address]
[DOCUMENT_ROOT] => /var/www/htdocs
[SERVER_ADMIN] => [email protected]
[SCRIPT_FILENAME] => /var/www/htdocs/index.php
[REMOTE_PORT] => 39746
[REDIRECT_URL] => /page-not-found.html
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /ec/basket.html?product_id=1
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
[PHP_AUTH_USER] =>
[PHP_AUTH_PW] =>
[REQUEST_TIME] => 1301662577
)
此處的HTTP狀態顯示404,但頁面正常顯示。只是我無法獲得$_GET
變量中的任何值。
此外$_GET
變量在同一網站上的其他頁面上工作得很好。
自從幾個小時以來,我一直在抓我的頭,但無法找到解決方案。任何幫助將不勝感激。
實際上任何重寫:
將其替換? – NikiC 2011-04-01 13:24:35
'[REQUEST_URI] => /ec/basket.html?product_id = 1'?爲什麼「.html」? – binaryLV 2011-04-01 13:29:28
看着這些變量,這是說請求是針對'/ec/basket.html?product_id = 1',並被重定向到'/ page-not-found.html' ...但是當前正在處理的文件是'/ index.php' ......令人困惑的是,至少可以說。 – Powerlord 2011-04-01 13:33:36