lunix 网站都已经建好批量301

lunix 网站都已经建好批量301

时间:2019-03-21 作者:xphero210 评论:0 点击:1101 次

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';


?>


已有 1101 位网友参与,快来吐槽:

发表评论

必填

选填

选填

◎欢迎参与讨论,发表您的看法、交流您的观点。