maketop’s blog

Just another WordPress weblog

下面是PHP, ASP, CGI和RoR的301转向代码写法。如果要验证是否对搜索引擎有效可以通过 http://www.webconfs.com/redirect-check.php 检查

PHP
<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.newdomain.com” );
?>

ASP
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.newdomain.com/”
%>

ASP.NET

CGI/Perl
$q = new CGI;
print $q->redirect(”http://www.newdomain.com/”);

Ruby on Rails
def old_action
headers[”Status”] = “301 Moved Permanently”
redirect_to “http://www.newdomain.com/”
end

Posted by admin on Wednesday, March 18th, 2009

Post A Comment

You must be logged in to post a comment.

    Popular Post

    Most Commented Posts

    Random Posts