新程序 发表于 2025-5-9 21:13:38

使用php进行301跳转2级域名的代码

<?php
    $host=$_SERVER['HTTP_HOST'];
    $host=explode(".",$host);
    $count_host=count($host);
    if($count_host==3){
    $host['0'].'.'.$host['2'];
    $ym="http://".$host['0'].".根域名";
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: $ym");//你的域名
}
if($count_host==2){
    $ym="http://需要跳转的域名";//你的域名
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: $ym");
}


页: [1]
查看完整版本: 使用php进行301跳转2级域名的代码