Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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):
I need to dynamically check their user agent and redirect them to either

It seems to me that I have two 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.

share|improve this question

Is there a reason the link to the file has to be It would be more straightforward if, instead of conditionally redirecting them at the web server level, your link was to (or cgi, or jsp, whatever) instead. In other words, basically option one, but making the file link directly to the script rather than redirecting.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.