background image

CURLOPT_STDERR: 这个文件写有错误而不是 stderr。

 

实例代码: 已测

<?php 
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 

// Date in the past 

@header("Last-Modified: " . 

gmdate

("D, d M Y H:i:s") . " GMT"); 

// always modified 

@header("Cache-Control: no-store, no-cache, must-revalidate"); 

// HTTP/1.1 

@header("Cache-Control: post-check=0, pre-check=0", false); 
@header("Pragma: no-cache"); 
@header("content-type:text/html; charset=utf-8"); 

$url

 = ''; 

$querystring

 = 

$_SERVER

["QUERY_STRING"]; 

$currentUrl

 = 

$_SERVER

['SERVER_NAME']; 

if

(

$querystring

 != '') 

$querystring

 = 

$querystring

 . "&"; 

$querystring

 = 

$querystring

 . "SiteURL=" . 

$currentUrl

if

(

$querystring

 != '') 

$url

 = 

$url

 . "?" . 

$querystring

$ch

 = curl_init(); 

$timeout

 = 60; 

// set to zero for no timeout 

curl_setopt (

$ch

, CURLOPT_URL, 

$url

); 

curl_setopt (

$ch

, CURLOPT_RETURNTRANSFER, 1); 

curl_setopt (

$ch

, CURLOPT_CONNECTTIMEOUT, 

$timeout

); 

$handles

 = curl_exec(

$ch

); 

//

 

下面是替换,可以结合服务器伪静态设置

$handles

 = preg_replace("/\?page=([0-9]+)&categoryId=([0-9]+)/i","/fenlei/category-$1-$2.html",

$handles

); 

$handles

 = preg_replace("/\?categoryId=([0-9]+)/i","/fenlei/category--$1.html",

$handles

); 

$handles

 = preg_replace("/\?page=([0-9]+)/i","/fenlei/category-$1.html",

$handles

); 

$handles

 = preg_replace("/infodetail\.aspx\?ID=([0-9]+)/i","/fenlei/$1.html",

$handles

); 

$handles

 = 

str_replace

("infolist.aspx","/fenlei/index.html",

$handles

); 

$handles

 = 

str_replace

("unionlist.aspx","unionlist.html",

$handles

); 

echo

 

$handles

?>