在网站根目录index.php文件中,其它语句前面加入以下代码:
//301_Redirect $the_host = $_SERVER['HTTP_HOST'];//取得当前域名 if(strtolower($the_host) != 'boliquan')//把这里的域名换上你想要的 { $URIRedirect=$_SERVER['REQUEST_URI']; //获取域名后的参数 if(strtolower($URIRedirect)=="/index.php")//判断是参数为/index.php就显示为/ { $URIRedirect="/"; } header("HTTP/1.1 301 Moved Permanently");//发出301头部 header("Location: /".$URIRedirect);//跳转到你希望的地址格式 exit(); }