2011-11-22 225 views

回答

2

的方法有很多,但我会解释一下其中的一些:

1.使用重写规则模块重定向 - mod_rewrite的:

选项+的FollowSymLinks

RewriteEngine叙述在

RewriteCond%{HTTP_HOST}^domain.com $ [NC]

重写规则^(。*)$ http://www.domain.com/ $ 1 [R = 301,L]

RewriteEngine叙述在

的RewriteCond%{HTTP_HOST} ^!万维网。(。*) [NC]

重写规则^(。*)$ http://www.%1/ $ 1 [R = 301,L]

2.使用重定向脚本:

PHP重定向:

<?php 
header(“HTTP/1.1 301 Moved Permanently”); 
header(“Location: 
http://www.newdomain.ru/newdir/newpage.htm”); 
exit(); 
?> 

ASP.NET重定向:

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

Ruby on Rails的:

def old_action 
headers[“Status”] = “301 Moved Permanently” 
redirect_to “http://www.new-url.com/” 
end 

*如果您需要更多信息,请写下我!

致敬*

+1

RewriteRule很棒!谢谢 ! – Didav