chombium Posted August 7, 2007 Share Posted August 7, 2007 Hi, I have a service that runs as a cgi-bin listener. Now I want to replace it with a php script. The cgi-bin executable it's named 'putdata' and has no extension and is accessed as http://IP_ADDR/path_to_cgi/putdata?user=sdf&pass=dfgf&data=sdfwewrrdsa.... I want to replace this putdata cgi-bin with some new php script possibly called putdata without the .php extension. I don't want to ask the users to change the access url. The server runs Apache 2 on Suse Linux So my question is: Is it possible to run a php script without an extension? Which configuration changes should be made to the apache web server to support php scripts placed in files without the .php extension. BR, Jovan Quote Link to comment https://forums.phpfreaks.com/topic/63728-solved-php-script-without-an-extension/ Share on other sites More sharing options...
Guardian-Mage Posted August 7, 2007 Share Posted August 7, 2007 make a .htaccess file(Open up notepad and save as .htaccess) and add this line ForceType application/x-httpd-php That forces a blank file with no extension to run as php Quote Link to comment https://forums.phpfreaks.com/topic/63728-solved-php-script-without-an-extension/#findComment-317550 Share on other sites More sharing options...
chombium Posted August 7, 2007 Author Share Posted August 7, 2007 Thanks for the fast reply, I was trying to do something with AddType :-\ Now I get the "save file as" dialog when I try to access the file with a web broswer. Seems to me the web server detects the file type, but doesn't know how to handle it. Problems with MIME-Types, or something else? Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/63728-solved-php-script-without-an-extension/#findComment-317570 Share on other sites More sharing options...
play_ Posted August 7, 2007 Share Posted August 7, 2007 what is the extension of file? Quote Link to comment https://forums.phpfreaks.com/topic/63728-solved-php-script-without-an-extension/#findComment-317584 Share on other sites More sharing options...
chombium Posted August 8, 2007 Author Share Posted August 8, 2007 what is the extension of file? The file has no extension. The problem I encountered after the reply from Guardian-Mage was because I added ForceType in the httpd.conf, and not in .htaccess file as was written in the reply. I found one interesting article at: http://www.devarticles.com/c/a/Apache/Using-ForceType-For-Nicer-Page-URLs/1/ Basically it suggests the same solution as Guardian-Mage, but in combination wiith the "Files" directive, you can easily define which files with no extension will be treated as php scripts. Here is an example: <Files my_file_name> ForceType application/x-httpd-php </Files> This tells Apache if a file named my_file_name is found in the url to treat it as a php script Quote Link to comment https://forums.phpfreaks.com/topic/63728-solved-php-script-without-an-extension/#findComment-318256 Share on other sites More sharing options...
Guardian-Mage Posted August 8, 2007 Share Posted August 8, 2007 Glad That I could help Quote Link to comment https://forums.phpfreaks.com/topic/63728-solved-php-script-without-an-extension/#findComment-318425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.