.htaccess 已删除,永久链接数据库条目
我在 php 应用程序中有事件条目,并带有事件的永久链接结构。我正在为 google 等创建动态 xml 站点地图
。它会在添加事件时创建新的 url 节点,并且当事件过去时,优先级会自动向下调整。
如果我的客户因某种原因决定删除该事件,我的问题与 404 not find 错误有关。显然,我会告诉我的 xml 站点地图删除 url 节点,但我是否应该写入我的 .htaccess
以及那些的 Redirect gone
因为它们会希望届时能被搜索引擎索引吗?
我很犹豫是否使用脚本对我的 .htaccess
文件进行任何写入,因为如果出现问题,它可能会彻底搞砸。
提前致谢。
I have event entries in a php application with a permalink structure for the events. I'm creating a dynamic xml sitemap
for google et al. which creates new url nodes as events are added, and when an event is in the past, the priority level automatically gets adjusted downward.
My question has to do with 404 not found errors if my client decides to delete the event for some reason. I will obviously tell my xml sitemap to remove the url node, but should I be writing to my .htaccess
as well with a Redirect gone
for those as well since they'll hopefully be indexed with the search engine by then?
I'm hesitant to use a script to do any writing to my .htaccess
file since it could screw things up royally if something should go wrong.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我基本上就是按照 Gumbo 上面所说的去做的。您可能想做的唯一一件事就是在 .htaccess 中设置一个自定义 404 页面,这样您就可以在用户从搜索引擎点击该页面时将其转发到外观更好的页面;只是类似于“未找到事件..但这里有一些类似的事件”的内容对于尝试引起他们对网站其他区域的关注很有用。
我不知道您的链接是如何设置的,但如果链接包含 SEO 关键字,您可以使用这些关键字来查找类似的事件,即如果 URL 是 /events/United_Kingdom/London/100,您可以使用该信息来查找类似的事件在伦敦。如果没有,您可以提取最新事件或一些随机事件。您甚至可以修改删除系统,以保留已删除事件的最少信息,以实现 404 页面的目的。
您确实需要确保保留 404 标头,以便搜索引擎不会将所有“丢失”事件视为重复内容。如果您不这样做,他们可能会在排名中惩罚您的网站。无论试图欺骗搜索引擎相信这是一个真实的页面以增加您的页面数量有多么诱人。
Google 发布了一些有关创建有用的 404 页面的信息,您可能想检查一下。
I'm pretty much just following on from what Gumbo said above. The only thing you might want to do is set-up a custom 404 page in your .htaccess so you can forward users to a nicer looking page should they hit it from a search engine; just something along the lines of "Event not found.. but here are some similar events" would be useful to try and get their attention to other areas of your site.
I don't know how your links are set-up but if the link contains SEO keywords you could use those for finding similar events, i.e. if the URL is /events/United_Kingdom/London/100 you could use that information to find similar events in London. If not you could just pull up the latest events or some random ones. You could even modify your delete system to hold onto minimal information of deleted events for the purpose of the 404 page.
You do want to make sure you keep the 404 header so that the search engines won't see all your 'missing' events as duplicate content. If you don't they may penalise your site in the rankings.. no matter how tempting it is to try and fool the search engines into believing this is a genuine page to boost your page count.
Google have published some information on creating useful 404 pages, you might want to check it out.