Trail: Home > Developer's Guide >

Configuring the web server

There are two potential issues when putting up a .cwz archive for downloading from a web server: the MIME type and the version number.

MIME type

The Cowry .cwz archive format is pretty new and will be unknown to most web servers. As a result, they'll tell the browser that the file is of type "text/plain", and the browser will try to display the archive as a page of text instead of downloading it to disk. To solve this problem on an Apache web server, create a file named ".htaccess" in your download directory with the following content:

AddType application/x-cowry .cwz

Version numbers

The other problem involves version numbers in file names. You should make sure that the name of the file downloaded to the user includes the version number in the name. But that means that you'd have to change all download links on every release.

If your web server supports PHP, you can have the version number in the file name, but still link to a stable download URL. Here's how: In your download directory, create a file named "download.php" with this content:

<?php
$host = $_SERVER['HTTP_HOST'];
$uri  = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
$file = "MyApp-2.1.cwz";
header("Location: http://$host$uri/$file");
exit;
?>

Then, link to "http://myhost.com/files/download.php/MyApp-current.cwz". The last part will be ignored by the script, but will provide a useful file name to browsers that don't handle this kind of redirect gracefully. Of course, you can extend the PHP script to handle different files or to determine the current version number dynamically.