Redirecting to a diferent exe for download based on user agent

Posted by Ra on Server Fault See other posts from Server Fault or by Ra
Published on 2010-02-19T09:36:44Z Indexed on 2010/03/23 9:03 UTC
Read the original article Hit count: 319

I own a Linux-Apache site where I host exe files for download.

Now, when a user clicks this link to my site (published on another site):
http://mysite.com/downloads/file.exe
I need to dynamically check their user agent and redirect them to either
http://mysite.com/downloads/file-1.exe
or
http://mysite.com/downloads/file-2.exe

It seems to me that I have to options:

  1. Put a .htaccess file stating that .exe files should be considered to be scripts. Then write a script that checks the user agent and redirects to a real exe placed in another folder. Call this script file.exe.

  2. Use Apache mod-rewrite to point file.exe to redirect.php.

Which of these is better? Any other considerations? Thanks.

© Server Fault or respective owner

Related posts about scripting

Related posts about apache