header(”Location: http://www.mvpec.com/articles/301/”);
exit();
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mvpec.com [NC]
RewriteRule ^(.*)$ http://www.mvpec.com/$1 [L,R=301]
RewriteEngine on
RewriteRule ^(.*)$ http://www.mvpec.com/$1 [L,R=301]
RewriteEngine on
RewriteRule ^news-(.+)\.html$ news.php?id=$1
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.mvpec.com/articles/301/”
%>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.mvpec.com/articles/301/“);
}
</script>
ServerName www.mvpec.com
DocumentRoot /home/mvpec
</VirtualHost>
ServerName lesishu.cn
RedirectMatch permanent ^/(.*) http://www.mvpec.com/$1
</VirtualHost>
response.setStatus(301);
response.setHeader( “Location”, “http://www.mvpec.com/” );
response.setHeader( “Connection”, “close” );
%>
print $q->redirect(”http://www.new-url.com/”);
server {
server_name www.hxj.com hxj.com ;
if ($host != 'www.hxj.com' ) {
rewrite ^/(.*)$ http://www.hxj.com/$1 permanent;
}
...
}
第二种方法:
server {
server_name hxj.com;
rewrite ^/(.*) http://www.hxj.com/$1 permanent;
}
这两种方法中, permanent是关键,详细说明见nginx重定向规则说明。
break – 中止Rewirte,不在继续匹配
redirect – 返回临时重定向的HTTP状态302
permanent – 返回永久重定向的HTTP状态301