I have an executable hosted at code.google.com (say, http://code.google.com/fold/file1.exe). When the user browses to http://mysite.com/download.exe, I want them to automatically get the content of the file http://code.google.com/fold/file1.exe without any redirect. The user should think that he/she is downloading the file from http://mysite.com/download.exe not http://code.google.com/fold/file1.exe.
How might I do this, using PHP? Is there any special term for this process?
You can use URL rewriting to pass in the file name as an argument to a script. Your script (downloadexecutable.php in this example) would respond to a $_GET argument ‘q’ which would contain ‘download’:
Then, you would enable URL rewriting on Apache in an .htaccess file in your root directory like so:
When the user requests any file ending in .exe, downloadexecutable.php should be executed as follows:
Request: http://yoursite.com/download.exe
What actually gets processed by PHP: http://yoursite.com/downloadexecutable.php?q=download
Request: http://yoursite.com/this/could/be/a/bug.exe
Processed: http://yoursite.com/downloadexecutable.php?q=this/could/be/a/bug
Obviously it would need a bit of work and I haven’t tested any of the above, but if you fool around with it a bit and are willing to use google, you should be able to get it working.
URL Rewriting tutorial: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
Source for the php stuff: http://snipplr.com/view/22546/