
lunix 网站都已经建好批量301
时间:2019-03-21 作者:xphero210 评论:0 点击:1188 次
lunix 网站都已经建好批量301 前提是你所有的网站都已经建好。
上传301.php到任何目录
然后执行命令 chmod +x 301.php
然后执行 php 301.php
301.php文件代码
<?php
$rpath = '/www/server/panel/vhost/nginx';
//$rpath = 'D:\\test';
$cfary = scandir($rpath);
foreach($cfary as $f) {
if($f != '.' && $f != '..') {
$fc = file($rpath.'/'.$f);
if(isset($fc)) {
$shost = $fc[3];
$thost = explode(' ',$shost);
if(isset($thost)) {
$mhost = $thost[5];
$whost = $thost[6];
$str301 = '
#301-START
if ($host ~ \'^'.$mhost.'\'){
return 301 http://'.$whost.'$request_uri;
}
#301-END';
$fc[5] .= $str301;
$resconf = iconv('gbk','utf-8', implode('',$fc));
@file_put_contents($rpath.'/'.$f,$resconf);
}
}
}
}
echo 'ok';
?>
本文标签:
转载请注明出处: http://www.iuseo.com/post/122.html
- 上一篇:WordPress网站替换URL域名
- 下一篇:Linux 下挂载磁盘操作
已有 1188 位网友参与,快来吐槽:
发表评论