虽然aspx中重定向有很多方式,如sendredirect和meta refresh,及js window.location.href ,但对搜索引擎最好的方式是301,对于.net>4.0的可以使用新方法
Response.RedirectPermanent
而之前的版本则可以使用
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "/");
Response.End();
来发送301重定向
tips
调试重定向时浏览器缓存很讨厌,因为直接重定向了,刷新的机会都没有,我就在上面浪费了很多时间,
解决方法1.关掉浏览器缓存,2使用浏览器的隐私模式
php:
header("HTTP/1.1 301 Moved Permanently");
header ("Location:$url");
注意之前不能有输出,包括没在<?php ?>里的空白字符,详见这里