我需要维护旧网址多久?
好的,我知道最好的做法是,一旦您更改或删除页面 URL,请将该 URL 重定向到新的相关 URL。
但持续多久呢?永远?
例如,我正在使用 Google 网站优化器来测试页面的不同变体。所以我必须为每个创建一个不同的url,例如:original.php、var1.php、var2.php等。
一旦测试完成,获胜者将成为新的original.php,并且无需保留var1 .php 等。但我现在需要将那些不再需要的 URL 重定向到相关的原始 .php。
这最终可能会成为我的 .htaccess
文件中的大量 301 重定向。我还听说 .htaccess 文件中的内容越多,站点的速度就越慢,因为服务器必须先处理其中的所有内容,然后才能提供页面。
我可以将重定向移动到实际的 URL(例如实际 var1.php 文件上的 php 重定向),但随后我的服务器上有几个不需要的文件。
所以我想知道这里的最佳实践是什么?经过这么长时间删除 301 重定向是否安全?
Ok, I know it is best practice that once you change or remove a page URL, to redirect that url to the new relevant URL.
But for how long? forever?
For example, I am using Google website optimizer to test different variations of a page. So I have to create a different url for each like: original.php, var1.php, var2.php, etc.
once the test is done, the winner will become the new original.php and there will be no need to keep var1.php, etc. But I now need to redirect those no longer needed URL's to the relevant original.php.
This can end up being a ALOT of 301 redirects in my .htaccess
file. I also have heard that the more stuff you have in your .htaccess file the slower your site becomes because the server has to process everything in it before it can serve a page.
I can move the redirects to the actual URLs (example a php redirect on the actual var1.php file) but then I have several unneeded files bloating up my server.
So I am wondering whats the best practice here? is it safe to remove a 301 redirect after so long?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以检查 Web 服务器的访问日志,了解这些 URL 上的 301 重定向。当它们不再出现在日志中(或很少出现)时,您可以根据需要删除重定向。去除它们没有特别的最佳时间。 “最佳”时间是旧 URL 不再使用的时间,而不同网站的时间可能会有很大差异。
You can check your web server's access logs for the 301 redirects on those URLs. When they no longer appear in the logs (or appear very rarely), you can remove the redirects if you feel like it. There is no particularly best time to remove them. The "best" time is when the old URLs are no longer used, and that can differ a lot from site to site.
当您测试变体时,这是一个私有 URL。只要没有外部链接并且您不公开它,您就可以在测试完成后销毁它。
如果您仅与组织中的其他人共享它,并同意它是短暂的,那么这是一个灰色区域。 Daniel Egeberg 关于保持转发一段时间的建议是文明的。
一旦您公开 URL,您必须将其视为存档。
这意味着您要确保它永远有效。我可能会容忍一些例外情况:
有人行使了不可抗力并关闭了整个域,例如 Geocities。不要让这种情况发生在您身上:不要将您有价值的网页置于营利性实体的控制之下。
有人以您无法拒绝的出价从您手下买下了您的域名。
您已经破产或无法再维持在线状态。
在这些情况下,您的道德义务是通过 archive.org 或 Jason Scott 提供您的内容,他拥有大量资源好的建议。
如果您控制自己的域并且让公共网址变得陈旧,您将在地狱中燃烧。
(鲜为人知的后但丁神学。)
When you are testing variations, that is a private URL. As long as there are no external links to it and you don't publicize it, you can destroy it when your tests are done.
If you share it only with others in your organization, under the agreement that it is ephemeral, that is a gray area. Daniel Egeberg's suggestion of maintaining forwarding for a time is civilized.
Once you make the URL public, you must treat it as archival.
That means you make sure it works forever. There are a couple of exceptions I might condone:
Someone has exercised force majeure and has shut down the entire domain, like Geocities. Don't let this happen to you: don't put your valuable web pages under the control of for-profit entities.
Someone has bought your domain out from under you with an offer you couldn't refuse.
You've gone bankrupt or can no longer afford to maintain a presence online.
In these cases, your moral obligation is to make your content available through archive.org or through Jason Scott, who has plenty of good advice.
If you control your own domain and you let a public URL go stale, you will burn in hell.
(Little-known post-Dante theology.)
也许有更好的方法来管理 .htaccess 文件。您的重定向是针对单页面、路径、子域还是域?
可以包含外部文件,以便您的重定向位于其自己的文件中,并且 .htaccess 包含该文件并保持整洁。
最后,可能有更好的方法来维护您的重定向。因此,不要关注重定向的维护时间,而是节省一些维护工作并更改您的问题以询问可以更轻松地添加和组织重定向的机制。 IIRC mod_rewrite 将执行此操作。必须有一种机制可以让您的服务器通过使用脚本(可能查询数据库)来确定重定向。至少,使用脚本来管理 .htaccess 文件重定向是明智的。
永不过期的重定向的一个优点是您也不必返回并清除旧的重定向。他们只是坐在那里,永远。如果您有过期的重定向,您现在需要执行第二个操作来删除旧的重定向。因此,您实际上通过使重定向过期做了更多的工作。
Perhaps there is a better way to manage your .htaccess file. Are your redirects for single pages, paths, subdomains, or domains?
It may be possible to include an external file, so that your redirects are in their own file and the .htaccess inlcudes that and stays uncluttered.
Finally, there may be a better way to maintain your redirects. So rather than focusing on how long to maintain your redirects, save some maintenance work and change your question to ask about mechanisms that make it easier to add and organize your redirects. IIRC mod_rewrite will do this. There has to be a mechanism that will let your server determine redirects by using a script (perhaps query a DB). At minimum, it would be smart to use a script to manage your .htaccess files redirects.
An advantage to never having redirects expire is that you also never have to go back in and clean out the old redirects. They just sit there, forever. If you have redirects that expire, you now have a second operation to perform to remove the old redirects. So you're actually doing more work by expiring redirects.
Norman,当然,如果一个页面是由 php 生成的,那么它就不能被视为“存档”。 php 几乎可以保证下次页面看起来会有所不同。如果您选择“不在那里”,那么这取决于您!
我还建议,如果人们正在使用这些页面,您可以通过不转发来弃用这些页面,而是在其中放置一个链接,告诉用户该页面已移动,并要求他们不要使用旧页面。放置一个链接供他们点击。这样做“一段时间”。我想这段时间取决于您预期的用户行为。您是否期望每个用户每月访问一次,或者它就像人们每年使用一次的纳税申报系统?
Norman, surely if a page is generated by php, then it can not be considered 'archival'. php almost guarantees that the page will look different next time. If by different you choose 'not there' then that is up to you!
I would also suggest that you may be able to deprecate these pages if people are using them, by not forwarding, but putting a link there telling the user that the page has moved, and asking them not to use the old one. Put a link for them to click. Do that for 'a while'. i guess the period on that depends on your expected user behaviour. Do you expect every user to have visited once a month, or is it like a tax return system which people use once a year?