服務器是否實際獲取請求,並且您是否正確處理主機名(別名)?
添加到我的.hosts後檔
檢查你的網絡服務器日誌,看看請求是如何進來的...
捲曲有選擇轉儲請求發送,接收到響應,它被稱爲跟蹤,它將被保存到一個文件。
--trace
如果你缺少主機或標題信息 - 你可以強制這些標題與配置選項。
我會得到在命令行上工作的curl請求,然後嘗試在PHP中實現。
配置選項是
-K/- 配置
是在捲曲相關的選項在這裏
--trace 允許所有傳入和傳出數據的完整跟蹤轉儲,包括描述性信息到給定的輸出文件。使用「 - 」作爲文件名將輸出發送到標準輸出。
This option overrides previous uses of -v/--verbose or --trace-ascii.
If this option is used several times, the last one will be used.
-K/- 配置 指定其配置文件中讀出捲曲的參數。配置文件是一個文本文件,可以在其中寫入命令行參數,然後將其用作在實際的 命令行上寫入的命令行參數。選項及其參數必須在相同的配置文件行中指定,用空格,冒號,等號或其任意組合(但優選的分隔符是等號)分隔。如果參數要包含空格,則參數必須用引號括起來。在雙引號內,可以使用以下轉義序列:\,\「,\ t,\ n, \ r和\ v。忽略任何其他字母前的反斜槓。如果配置行的第一列是'# '字符,該行的其餘部分將被視爲評論。只能在配置文件中根據 物理線路寫入一個選項。
Specify the filename to -K/--config as '-' to make curl read the file from stdin.
Note that to be able to specify a URL in the config file, you need to specify it using the --url option, and not by simply writing the URL on its own line. So, it could look similar to this:
url = "http://curl.haxx.se/docs/"
Long option names can optionally be given in the config file without the initial double dashes.
When curl is invoked, it always (unless -q is used) checks for a default config file and uses it if found. The default config file is checked for in the following places in this order:
1) curl tries to find the "home dir": It first checks for the CURL_HOME and then the HOME environment variables. Failing that, it uses getpwuid() on UNIX-like systems (which returns the home dir
given the current user in your system). On Windows, it then checks for the APPDATA variable, or as a last resort the '%USERPROFILE%\Application Data'.
2) On windows, if there is no _curlrc file in the home dir, it checks for one in the same dir the curl executable is placed. On UNIX-like systems, it will simply try to load .curlrc from the deter-
mined home dir.
# --- Example file ---
# this is a comment
url = "curl.haxx.se"
output = "curlhere.html"
user-agent = "superagent/1.0"
# and fetch another URL too
url = "curl.haxx.se/docs/manpage.html"
-O
referer = "http://nowhereatall.com/"
# --- End of example file ---
This option can be used multiple times to load multiple config files.
我得到400與PHP的錯誤,當我手動與curl.exe請求我得到服務器的默認索引,這意味着它不尊重'HOST'標題。 – Xeoncross 2010-08-11 15:29:40
我用虛擬主機在各種服務器上嘗試過它,它可以工作(從命令行)。爲了以防萬一(儘管我認爲它不應區分大小寫),請嘗試使用'Host'而不是'HOST'。正如我所說的,確保你只在Host標頭中使用主機名,沒有別的(後面沒有'http://'和沒有'/ something')。 你是如何設置你的主機文件的? – Bruno 2010-08-11 15:37:15
發佈了更多關於下面這個結果的數據。 – Xeoncross 2010-08-11 15:44:33