Got Chance

single download link that changes automatically

Single Download Link That Changes Automatically

If you are familiar with WordPress, you should know that the WordPress site has a link http://wordpress.org/latest.zip. If the current release is 2.7, that link will download version 2.7. If 2.7.1 gets released, that link will download that for you. I’ve always loved that feature. So, when I recently launched my open source script Rotatee, I decided to steal that feature. So, if you visit http://rotatee.com/latest.zip, it’ll automatically download the latest version for you.

This can be achieved by a very simple method. If requires you to edit your .htaccess file in your domain root folder. Simply add this line to your .htaccess :

RedirectPermanent /latest.zip FULL-LINK-TO-THE-DOWNLOAD-FILE

or

RewriteRule latest.zip FULL-PATH-TO-THE-DOWNLOAD-FILE [R=301,L]

You have to update this file with the new link once you release a new version. In my case, it is currently:

RedirectPermanent /latest.zip http://rotatee.googlecode.com/files/rotatee-1.2.zip

This is the way I do it currently. If you know a simpler method, do let me know. And the advantage of using this technique is that you can simply refer as "download the latest version here" and point to this latest.zip link when you write blog posts or anything like that. Also, if you have "Download" links through out your site on many places, you need not update each of them individually. You can simple point them to this link.

Of course, this technique must have some other uses too. But, I can’t think of any, at the moment. If you know, do share with us.

29 Responses

Hi:

The latest download feature of wordpress is indeed good. However I wouldn’t really go with the .htaccess approach.

Are you serving the file statically? If that’s the case only .htaccess makes sense. Otherwise you can simply start streaming the latest version without any need for redirect.

Secondly, I don’t think it should be a permanent redirect, in your .htaccess you should do a 302 redirect.

In fact an external redirect is not required an internal rewrite will be sufficient to serve the correct file. This way the actual location of the latest version is never exposed and people don’t ‘bookmark’ the old version. :)Would love to hear from you.

Hey Jeet,

Firstly, I don’t understand what you exactly mean by serving the file statically ? Yes, the file is stored on the server. So, it is static.

Secondly, why do you suggest 302 redirect ?

I used external redirect because my project files are stored on Google’s servers.

Static means served directly from the file system rather than through a script.

A 302 redirect is suggested because it’s NOT a permanent redirect at all. It’s a temporary redirect to (say) version 7.1, after a month it will redirect to version 7.2.

I understand the reason for external redirect here. But for those hosting the file on their own servers, it might make sense to just do a URL rewrite.. I hope you agree..

Anyways, it would be great if you can also give another .htaccess syntax to your readers.

RewriteRule latest.gz FULLPATH_TO_LATEST_VERSION [R=301,L]

Yeah, it is a static file..

And yes, a 302 redirect seems logical than a 301 redirect.

Yeah i agree with you that a URL redirect is just fine for a file hosted on the same domain.

I’ve now added the other syntax also to the post. 🙂

Interesting approach to this. Wouldn’t it be just as easy to upload a new file and fix the link on the page to that new file?

Hey Bill,

That sure is possible.. But not the easiest.. Just that, this method simplifies the process and also gives you some advantage..

We had been doing it Bill’s way at work, but when I showed them your post the boss changed it. Thanks Hari!

@Shellie,

🙂 Cool.. Glad it was helpful..

wow.. very Cool.. Really very helpful.. will implement this soon in my blog

nice trick, will give it a try when i setup my blog soon

thanks for the tip. i’ll try and implement this in my blog

Do you have a similar solution for ASP on IIS?

I want ask:

RedirectPermanent /latest.zip or http://wordpress.org/latest.zip ??

thank you

I really liked your blog!will chck back soon again thx

Very nice information. Thanks for this.

Hi, Like the sense of humor in the articles. The site is a literary masterpiece. This site is capital constantly providing fairness reviews and infos.

Great informative site, this method will help all.

nice blog. its will help me. Thanks

This is such a cool tip. I can totally use this on one of my sites right now. I never thought about using the .htaccess to handle this situation. Now I can provide a static link and point that to any location on the server. VERY COOL! So simple, yet so effective. Well done.

I’m coding a PHP script but haven’t figured out how to serve the download system. I needs stats, among other features. Nice information you have here. Keep it up!

I really liked your blog with the Red Sox mention!

As a UK-based acne sufferer, I found your blog on google and read a few of your other dermatology posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

Can you provide more information on this for the rest of us doll collectors?

I really liked your blog!

I really liked your blog!

This is a really great site with alot of good well written post.Found this via google and will be coming back.Thanks