开发者

How do I provide a URL that will always download the latest version of a file?

开发者 https://www.devze.com 2023-01-05 13:22 出处:网络
I want to provide a URL such as \"...mysite.com/my_installer.exe\", but I want to be able to make it point to the latest version of my installer.

I want to provide a URL such as "...mysite.com/my_installer.exe", but I want to be able to make it point to the latest version of my installer.

So if I create version 2 of the installer, the url will download "...my_installer_v2.exe".

I've looked at general URL redirection - 301 redirects, .htaccess etc - but they seem to be geared towards web pages, I'm not clear which, if any, would be appropriate, or if I should be approaching it differently.

If it's relevant, I'm on开发者_运维技巧 an apache server, using a PHP based CMS (Textpattern).


Must people have a copy that is "My_Installer_Latest.exe" which is replaced when a new version is released. So just point to that one and replace it when a new version comes.

You have the other versions as well "My_Installer_V2.exe", the only difference is the file that you replace each time a new version is uploaded. Very easy to do and fool proof


It migth be not the answer your looking for but when you write URL they need to have a meaning so the rigth thing to do, in my opinion, is your url should be something like mysite.com/last_version and then you can redirect that last_version to a php page (in your case) that is able to select the rigth download.

I mean I'm assuming you want to do it in a "smart way". You can always just replace the file everytime you update your software.


You could use Apache's mod_rewrite.

If you're using Apache, then perhaps you're also hosted on a unix system, and could simply use symbolic links: ln -fs my_installer_4496.exe my_installer.exe. Every upload, change the symbolic link to point to the new file.


On a unix system, you might start with "...mysite.com/my_installer_v1.exe" as a file and have served a link "...mysite.com/my_installer.exe" pointing to this version 1 file. So if version 2 enters the stage or maybe a daily/nightly build with a timestamp as version, you have the link updated on the filesystem and do not have to change the interface code in the CMS (html served to the client).

If there is a need to allow access via the web to older or unstable parallel versions, you can always refer to the real filename as href attribute in the a-element of the html. In case you need it on the shell issue a command like ln -s my_installer_v1.exe my_installer.exe after having changed into the directory holding the file (the one being served as "...mysite.com/" in your example. The link in the html page would be something like <a href="/my_installer.exe">my_installer.exe (latest version)</a>.

PS: ln -fs my_installer_v2.exe my_installer.exe would be the (f means force) next update in your scenario.

0

精彩评论

暂无评论...
验证码 换一张
取 消