帮助处理来自我网站的传出链接的 301 重定向
我工作的公司通过跟踪合作伙伴的第三方网站链接到合作伙伴。 例如,在我们的网站上会有一个类似这样的传出链接(名称已更改以保护我的工作):
<a href="link.php?link=chuckecheese">check it out kids!</a>
如果您进入 link.php,您会看到我在那里定义了链接:
$outlink['chuckecheese'] = "http://partners.linktrackingisprettycool.com/x/212/CD1/$STAMP";
$STAMP 是一个时间戳,并替换为,例如,圣诞节中午为“12-25-09-1200”。
当用户点击此链接时,他会访问 www.chuckecheese.com
这一切都很好,但对于 SEO 目的来说,它并不那么好。 我想让搜索引擎将其视为chuckecheese.com 的链接,这有助于我们合作伙伴的页面排名并且更加诚实。
我在 .htaccess 中试图制定重写规则,但我很困惑并且不知道它到底是如何完成的。 我尝试过:
RewriteRule http://www.chuckecheese.com$ link.php?link=chuckecheese$ [QSA]
但这似乎不起作用。 接下来我应该尝试什么?
预先感谢您的任何帮助。 这里的你们总是很棒,我很欣赏 Stack Overflow 的优秀人员在我继续工作中所扮演的角色。
I work for company that links out to partners through a third party website that tracks them. So for example on our site there will be an outgoing link something like this (names changed to protect my work):
<a href="link.php?link=chuckecheese">check it out kids!</a>
if you go into link.php, you see I define the link there:
$outlink['chuckecheese'] = "http://partners.linktrackingisprettycool.com/x/212/CD1/$STAMP";
$STAMP is a timestamp and is replaced with, say, "12-25-09-1200" for noon on christmas.
When a user clicks on this link, he goes to www.chuckecheese.com
This all works fine, but it isn't as good for SEO purposes as it could be. I want to make it so that search engines will see it as a link to chuckecheese.com, which which helps our partners' pageranks and is more honest.
I'm in .htaccess trying to make up rewrite rules but I'm confused and don't know exactly how it's done. I tried:
RewriteRule http://www.chuckecheese.com$ link.php?link=chuckecheese$ [QSA]
But this doesn't seem to work. What should I try next?
Thanks in advance for any help. You guys on here are always awesome and I appreciate the part that the good people at stack overflow play in me remaining employed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不能为此使用重写规则来重定向用户。 该请求必须由您的网络服务器处理。
您可以尝试执行一些 javascript 来实现此目的。 所以href是chuckecheese,但是onclick,你将document.location更改为你真正想要做的。
编辑赏金问题
您可以做的是根据浏览器的用户代理预处理您的链接。 因此,当用户代理是 googlebot (以下字符串之一)时,您将显示 http://www 的真实网址。 Chuckecheese.com。
当 URL 不是 googlebot 时,您将显示进行流量分析的链接。
您可以在以下网址找到用户代理列表:
如果 googlebot 没有显示正确的用户代理(或者将来会发生变化),google 建议您对 IP 地址进行反向查找。 这将对性能造成很小的影响。
已编辑以获取进一步说明< /b>
假设您使用的是 php,您会在运行时生成链接。 这是我编写的一些代码。
我怀疑谷歌会关心这样的事情,因为两个链接都指向同一个地方。
但请检查服务条款以确定。
http://www.google.com/accounts/TOS
You can't use a rewrite rule to redirect the user for this. The request has to be one processed by your webserver.
You might try doing some javascript to achieve this. so the href is to chuckecheese, but onclick, you change the document.location to what you really want to do.
Edited question for bounty
What you could do is pre-process your links based on the user agent of the browser. So when the user-agent is googlebot (one of the below strings), You display the real url of http://www.chuckecheese.com.
When the URL is not googlebot, you display the link that does traffic analytics.
You can find a list of user agents at the following URLs:
If googlebot isn't showing the correct user-agent (or it changes in the future) google recommends you do a reverse look up against the IP address. This will be a small performance hit.
Edited for further explanation
Assuming you are using php, you generate the link at runtime. Here is some code I whipped up.
I doubt google would care about something like this since both links go to the same place.
But check the TOS to be sure.
http://www.google.com/accounts/TOS
你的假设并不好。 你说:
如果这真的有助于 SEO,那么每个人都会垃圾邮件链接所有优秀的网站,只是为了获得 SEO 页面排名,而游戏就太简单了。 链接的受益人是收件人页面/站点,而不是发件人。
An assumption of yours is not good. You say:
If this really helped SEO wise, every body would spam link all great sites just to get SEO pagerank and the game would just be too easy. The beneficiary of a link is the recipient page/site, not the sender.
嘿,PG...链接到其他网站不会给您带来任何进一步的 PageRank,就像您在 AdWords 中的广告出现在一千个其他网站上不会给您带来 PageRank 一样。 是的,您的合作伙伴会因您与他们的联系而受益。 那么您所说的开放带来的好处又是什么呢? 根据我对你所写内容的理解,这只是另一个奇特的重定向。 谷歌知道这一点。
Hey PG... linking out to other websites will not give you any further PageRank just as having your ads in Adwords appearing on a thousand other sites will not give you PageRank. And yes, your partners are being benefited by having you linked to them. And what about those benefits to be gain that you speak of from being open? From my understanding of what you have wrote, it is just another fancy redirect. Google knows that.