程序是ASP的,只需在index.asp首页的头部加入下面的代码,0769cm.com换成你自己的域名。
<%
if request.ServerVariables(“HTTP_HOST”)=”0769cm.com” then
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”https://www.0769cm.com/”
Response.End
end if
%>
如果程序是PHP的,只需在index.php首页的头部加下以下代码,mom1.cn换成你自己的域名。
<?php
if($_SERVER[“HTTP_HOST”] == “0769cm.com”)
{
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location:https://www.0769cm.com/”);
}
?>
以上两种方法只适合在首页没有缓存的情况下使用,如果缓存首页以上方法不会生效。
记住代码中的www不要删掉!
免费学习国学文化,请点击“国学讲堂” 【总裁课堂】