2013-08-21 72 views
3

我正在使用HTML2PS,並且它在舊服務器上正常工作,已移至新服務器並停止工作。404在找到同一臺服務器時找不到

我已經分離,我通過捲曲訪問臨時文件不是從服務器中,但該文件可以從其他位置獲取(如我的本地機器)

此URL可能不靠近工作中的問題未來,因爲我可能會刪除此鏈接。

http://www.lapchi.com/new/temp_curl.php5

鏈接的代碼是如下

<form method="post"> 


<input type="text" name="url" value="http://www.lapchi.com/new/uploads/temp/html_pdf/503_S_b7ku0sbn1i8g8ll06ra1pth332.html" size="90" /> 
<input type="submit" value="go"> 
</form> 
<?php 


set_time_limit(8888); 

if($_POST){ 
$url = $_POST['url']; 
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL,$url); // this file is physically exist on server 
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7) Gecko/20040803 Firefox/0.9.3"); 
curl_setopt($curl, CURLOPT_HEADER, 1); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 

$response = curl_exec($curl); 
if ($response === FALSE) { 
    error_log(sprintf('Cannot open %s, CURL error is: %s', 
      $url, 
      curl_error($curl))); 
    curl_close($curl); 
    return null; 
} 

curl_close($curl); 
preg_match('/^(.*?)\r\n\r\n(.*)$/s', $response, $matches); 

$headers = array_slice(explode("\r\n", $matches[1]),1); 
$content = $matches[2]; 


echo $content; 

} 

我不知道,爲什麼同一臺服務器上相同的文件無法通過捲曲被發現,但其他人可以CURL這個網址,這頁面可以捲曲的網址

+0

也許是因爲你試圖訪問與捲曲相同的域?合併已經存在於您運行腳本的服務器上的東西是沒有意義的。 – silkfire

+0

爲什麼你會使用curl如果它在同一臺服務器上並且可以通過php訪問? –

+0

HTML2PS是使用CURL創建PDF文件的開源代碼,我面臨的問題是生成的PDF文件顯示'NOT FOUND',所以我創建了這個測試用例。 –

回答

0

它是由在/ etc加入74.208.15.19 server.com www.server.com解決/ hosts文件,現在它正在

1

我會繼續這樣的:

  1. 在shell [R未捲曲http://www.lapchi.com/new/uploads/temp/html_pdf/503_S_b7ku0sbn1i8g8ll06ra1pth332.html
  2. ,如果它不工作,一定有什麼不對您的DNS設置的
+0

是的,它不能在shell中工作 –

+0

使它在shell上工作,那麼它將在PHP中工作。您可能會嘗試在您的腳本或shell中用127.0.0.1替換www.lapchi.com。 – schoash

+0

無法將其更改爲「http://127.0.0.1/new/uploads .... .html」,因爲它正在爲虛擬主機提供服務 –

3

重複:

Can I do a CURL request to the same server?

它真的沒有意識到應該在應用程序服務器上已經存在的東西。

+0

同意。這種方法看起來不提供任何可行的功能。 – itachi

+0

與我的其他問題相關http://stackoverflow.com/questions/18353369/html2ps-generated-pdf-file-stopped-working-after-server-tranfer-showing-not-foun HTML2PS需要運行這個,我需要獲取HTML的PDF –

相關問題