下面简单说在网页当中如何设置301重定向!
1asp程序:
<%
dim Url: Url=request.ServerVariables("HTTP_HOST")
if Url="ywlcm.net" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",""
Response.End
end if
%>
<%
if request.ServerVariables("HTTP_HOST")<>""then
Response.Status="301MovedPermanently"
Response.AddHeader"Location",""
Response.End
endif
%>
2PHP程序:
$hostdomain=$_SERVER['HTTP_HOST'];
if ($hostdomain != '') {
header("HTTP/1.1 301 Moved Permanently");
header("location:");
exit();
}
?>
3伪静态301代码!~
加在index.php中的
php 后面
$jump301=1;
if(substr($_SERVER['SERVER_NAME'],0,4)!=''&&$jump301)
{
header('HTTP/1.1 301 Moved Permanently');
header('Location:'.$_SERVER['SERVER_NAME']);
exit();
}
4js跳转代码
[xss_clean]
if(document.domain!='')
this.location=""+this.location.pathname+this.location.search;
[xss_clean]
如有盆友看不懂的,可以给我留言哦,相互学习。