2011-11-22 125 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