litespeed 下配置 伪静态,反向代理
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^(.*).html$ index.php?static_url=$1 [L]
</IfModule>
以上可以实现URL重写,仅限于站内 暂时无法配置反向代理。
不过LiteSpeed下,可以利用URL重写规则,首先重写至站内某PHP文件,利用此文件远程抓取实现 反向代理
RewriteRule ^(news-.*\.html)$ daili.php?a=$1
daili.php代码:
<?php
function Curl($url,$time=3){
$ch2 = curl_init();
$user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us)AppleWebKit/532.9(KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7";//模拟iphone登陆
curl_setopt($ch2, CURLOPT_URL, $url);
curl_setopt($ch2, CURLOPT_TIMEOUT, $time); //3秒钟超时
curl_setopt($ch2, CURLOPT_HEADER, false);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_REFERER, 'XXX.com');//模拟来路
curl_setopt($ch2, CURLOPT_USERAGENT, $user_agent);
$temp=curl_exec($ch2);
return $temp;
}
$a = $_GET['a'];
if($a == '') exit();
echo Curl('http://抓取的网址/'.$a);
?>