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.