I have a number of geographical datasets in a database that I would like to visualize as kml-files. For google earth to behave correctly, it is not just enough that the “Content-Type” is correctly set. The file must end with a .kml.
Again, mod_rewrite to the rescue. The following line in my .htaccess file:
RewriteRule dataset-(.*).kml$ /mobilweb/kml.php?fileid=$1
I.e, when I make an url that ends with fileid-
RewriteRule dataset(.*)-(.*).kml$ /mobilweb/kml.php?fileid=$2&color=$1
Here I specify a colorcode just followint the keyword dataset, the id comes after the hyphen. Of cource, I must sanitize the id and color codes correctly in the script and also handle it correctly if they are invalid or missing.