我们可以用javascript进行302重定向吗? [英] Can we do 302 redirect with javascript?

查看:428
本文介绍了我们可以用javascript进行302重定向吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或者它必须是服务器端吗?

Or does it have to be server side?

目前谷歌要求所有网站都是302到一个页面而不是通常的页面。

Currently google requires all sites to 302 to a page rather than the usual pages.

如何使用javascript完成此操作?我可以在meta或者其他内容中打印302代码吗?

How do I do so with javascript? Can I just print a 302 code in meta or something?

注意:抱歉。这不是谷歌的搜索引擎。这是google bodis.com above.com的网站提供商namedrive.com以及其他一些人。

Note: sorry. This is not google for search engine. This is google the feed provider for bodis.com above.com namedrive.com and a bunch of other guy.

我是域名parker。我获得了在搜索引擎中排名的域名,并将流量转移到其他地方。问题是谷歌现在禁止URL转发。我只是想如何用更透明的转发来维持我的排名,例如302.目标网址很漂亮,我会说空白。

I am a domain parker. I get domains ranked at search engine and move traffic somewhere else. The problem is google now prohibit URL forwarding. I am just thinking how do I maintain my ranking with more transparent forwarding such as 302. The destination URL is pretty, I would say blank.

推荐答案

这是302重定向的工作原理:

This is how a 302 redirect works:

HTTP 302 表示已找到。在某种程度上,服务器告诉客户端在哪里检索它所请求的页面。

HTTP 302 means found. In a way, the server tells the client where to retrieve the page it requested.

示例:

客户发送:

GET /index.html HTTP/1.1
Host: www.yourdomain.com

服务器响应:

HTTP/1.1 302 Found
Location: http:/yoursubdomain.someotherdomain.com/somefolder

这就是为什么你无法使用javascript实现302重定向。它是HTTP协议的一部分。在执行重定向之前,客户端的浏览器不会加载任何页面。

This is why you couldn't achieve a 302 redirect using javascript. It's part of the HTTP protocol. No page gets loaded by the client's browser before the redirect is performed.

这篇关于我们可以用javascript进行302重定向吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆