Extension-less PHP file

Hi.

I have a PHP file invoking and handling file downloads, instead of having www.somedomain0.com/download.php?id=### , I have followed the advice on http://richardlynch.blogspot.com/2006/06/php-downloads-content-disposition.html

to instead make it work with links looking like this: www.somedomain0.com/download/###

I have therefore saved the script without an extension, and as is suggested in the above linked article created a .htaccess file including these lines

<Files download>
ForceType application/x-httpd-php
</Files>

But it does not send it to PHP for processing, rather it just invokes a download dialogue for the script.

What more do I need to do to make this particular file be processed by PHP?

Alle,

The ForceType directive is the preferred choice when there is a file extension but that command is designed to require three parts: ForceType, the type and the file extension. Without seeing your code, I’d guess that you don’t have the requisite space after the type and I’m not sure how to get Apache to recognize a null file extension - ForceType.

Regards,

DK

Thank you for the reply. I was not working on this for a while.

I do not know what a 404 script is. But I suppose handling redirect at “file not found”.

My file is saved as ‘download’, without any extension. So /download does get to the file, but it prompts a download dialogue for it.

My intention was not to use mod rewrite, but the ForceType directive. It does seem to alter the type to “application/x-httpd-php”, but it is not parsed by PHP. I cannot figure out just why it is not working, I tried this with two different files. Maybe the PHP configuration needs to be altered as well? The technique is explained here http://www.devarticles.com/c/a/Apache/Using-ForceType-For-Nicer-Page-URLs/1 .

I tried the .htaccess and mod_rewrite test published on your website, and it all works on the server. So I will learn to use mod_rewrite instead.

Still curious as to why my “download” file is not parsed by PHP.

Thanks again.

Alle,

The problem you are having is that your requests are not getting to download.php to be served. You COULD use a 404 script to handle download/### requests but it would be far easier to use some mod_rewrite to do the trick directly (redirect the download/### requests to download.php?id=### but “hide” the redirection).

If you’ve got mod_rewrite available, it’s a SIMPLE redirection (I won’t repeat the code here as it’s already in my tutorial - linked in my signature with a full explanation) - if not, the tutorial begins with enabling mod_rewrite.

Regards,

DK