301重定向跳转页面代码写法asp/php

我们有时需要更换网页存放目录,如果不担心搜索引擎排名问题的话,直接写一条ASP语句redirect就可以了。

<%response.redirect "http://yangjunwei.com" %>

如果要考虑搜索引擎的话,那就要用301永久重定向了,代码如下:

ASP下的301转向代码:

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://yangjunwei.com"
%>

ASP.Net下的301转向代码:

<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location",http://yangjunwei.com/");
}
</script>

PHP:

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://yangjunwei.com" );
?>