KML文件类型的搜索引擎优化 [英] Search engine optimization for kml file type

查看:68
本文介绍了KML文件类型的搜索引擎优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生成kml文件的网站.像这样的uri: /tokml?gid = 2846

I've a web site that generates kml files. An uri like this: /tokml?gid=2846

生成如下文件: 公吨. Dana Summit Trail.kml

Generates a file like this: Mt. Dana Summit Trail.kml

在PHP脚本中使用Header('Content-Disposition: inline; filename="Mt. Dana Summit Trail.kml"');并在Apache http服务器上运行.

Using Header('Content-Disposition: inline; filename="Mt. Dana Summit Trail.kml"'); in a PHP script and running on Apache http server.

但是在filetype:kml上进行的Google搜索不会显示我的网站的任何结果.我可以缓存所有kml文件,并建立一个像这样的uri:/kml/Mt. Dana Summit Trail.kml

But a Google search on filetype:kml will not give any results from my web site. I could cache all kml files and build an uri like this: /kml/Mt. Dana Summit Trail.kml

但是还有其他解决方案吗?

But are there any other solutions?

推荐答案

根据我的经验,Google通常会对查询字符串中带有标识符的URL进行很好的索引-因此,搜索filetype:kml.如果您可以发布指向所讨论站点的链接,或者提供从请求到/tokml?gid=2846的响应标头的完整副本,那将是很好的-这些标头中可能隐藏有某种阻止程序".

From my experience, Google usually index URLs with an identifier in the query string quite well - thus, it seems strange that nothing at all shows up when searching for filetype:kml. It would be nice if you could post a link to the site in question, or provide a complete copy of the response headers from a request to /tokml?gid=2846 - there might be some kind of "blocker" hidden in those headers.

为每个文档分配一个真实的" URL(不带查询字符串参数)通常是一个好主意,并且您无需对KML文件进行磁盘缓存即可实现此目的.如果您的PHP应用程序托管在Apache上,则可以让 mod_rewrite 转换漂亮的URL通过将其包含在应用程序的.htaccess文件中

Assigning a "real" URL (without query string parameters) for each document is usually a good idea, and you should not need to disk cache your KML files to achieve this. If your PHP application is hosted on Apache, you can let mod_rewrite translate the pretty URLs into the query string versions, by including this in a .htaccess file for the application:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^kml/([^.]+)\.kml$ tokml?slug=$1 [NC]

您可能想在数据模型中添加一个额外的字段,以为每个KML文件保留一个"URL slug".该值通常与文件名几乎相同,但全部为小写且没有任何特殊字符-例如. mt-dana-summit-trail.通过在URL中使用此字段而不是实际名称,用户和漫游器将避免看到充满丑陋的编码字符值的URL.

You might want to add an extra field to your data model, to hold a "url slug" for each KML file. The value would typically be almost the same as the name of the file, but all lowercased and without any special characters - eg. mt-dana-summit-trail. By using this field in the URL instead of the actual name, users and robots will avoid seeing URLs full of ugly, encoded character values.

每当您写出指向KML文件的链接时,请使用新的URL样式:

Whenever you write out a link to a KML file, use the new URL style:

<a href="/kml/mt-dana-summit-trail.kml">Mt. Dana Summit Trail</a>

在您的tokml脚本中,然后检索slug查询字符串键,并在查找相关数据对象时使用它-而不是gid.请注意,重写规则是如何捕获url slug的,并将其作为良好的老式查询字符串参数传递给脚本.

In your tokml script, retrieve then slug query string key, and use this - instead of gid - when looking up the relevant data object. Notice how the rewrite rule makes a capture of the url slug and passes it to the script as a good old fashioned query string parameter.

这篇关于KML文件类型的搜索引擎优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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