直播中
<%
if request.ServerVariables("HTTP_HOST")<>www.b.com then
if Request.ServerVariables("SCRIPT_NAME")="/index.html" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","/index.html"
else
if Request.ServerVariables("QUERY_STRING")<>"" then
p="?"
else
p=""
end if
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.b.com"&Request.ServerVariables("SCRIPT_NAME")&p&Request.ServerVariables("QUERY_STRING")
Response.End
end if
end if
%>
如果你使用的并不是全站动态程序,而是生成静态的程序,请使用下面的代码来进行域名也就是首页的301永久重定向。
ASP程序的301重定向
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.xiaojian.org"
%>
PHP下的301重定向
PHP程序的301重定向
<?
Header( "HTTP/1.1 301 Moved Permanently" ) ;
Header( "Location: http://www.xiaojian.org" );
?>
ASP.NET程序的301重定向
<script runat="server">
PRivate void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader ("Location",http://www.xiaojian.org);
}
</script>