English 中文(简体)
Search engine optimization for kml file type
原标题:
  • 时间:2009-12-09 09:37:09
  •  标签:
  • php
  • seo
  • kml

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

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

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

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?

最佳回答

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.

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]

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.

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>

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.

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签