标签:
1、302重定向是暂时的重定向,搜索引擎会抓取新的内容而保留旧的网址。因为服务器返回302代码,搜索引擎认为新的网址只是暂时的。 SEO 302好于301
2、301重定向是永久的重定向,搜索引擎在抓取新内容的同时也将旧的网址替换为重定向之后的网址。
1. html语法
<head> <meta http-equiv="refresh" content="1;url=http://www.taobao.com"> </head>
content中1表示跳转的间隔时间1秒钟后挑转,0表示直接跳转。后面是具体要跳转的页面
2. js实现
<script> setTimeout(function () { location.href = ‘http://www.taobao.com‘; }, 2000); </script>
nodejs实现的代码:
var connect = require(‘connect‘); var app = connect(); app.use(‘/public‘, connect.static(__dirname + ‘/public‘)); app.use(‘/redirect‘, function (req, res, next) { res.statusCode = 302; res.setHeader(‘Location‘, ‘http://www.taobao.com‘); res.end(); });
<META HTTP-EQUIV=REFRESH CONTENT="1; URL=http://www.example.org/bar">
Why? because it could break the "back" button. Imagine that the user presses the "back" button, the refresh would work again, and the user would bounce forward. The user will most likely get very annoyed, and close the window, which is probably not what you, as the author of this page, want.Use HTTP redirects instead
参考:
https://www.w3.org/QA/Tips/reback
标签:
原文地址:http://www.cnblogs.com/chenlogin/p/5594387.html