RewriteEngine On

# Temporary lock files are runtime state, not public downloads.
RewriteRule ^tmp(?:/|$) - [F,END]

# Planet64 already renders these coordinates with mod_tile. Do not add a
# second Seekarte disk cache or a PHP-to-HTTP round trip there.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SERVER_NAME} ^(planet\.freietonne\.de|planet64\.jesse\.de|planet64|10\.10\.60\.8)$ [NC]
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)\.png$ /osm/$1/$2/$3.png [END]

# On ftdl, existing PNG files are served directly. Missing tiles and all
# legacy/portable requests use the PHP endpoint with role-specific sources.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)\.png$ TileCache.php?z=$1&x=$2&y=$3 [END]
