Forum Moderators: phranque

Message Too Old, No Replies

How do I use extensionless files w CGI?

ForceType doesn't work w CGI, ideas anyone?

         

E_Flat

11:45 pm on Nov 16, 2007 (gmt 0)

10+ Year Member



I run a portal with no file-extensions and forcetype in .htaccess like this:

DirectoryIndex index
<Files *>
ForceType application/x-httpd-php
</Files>

We are porting to Apache with FastCGI on Windoze but it seems like it is impossible to run files without extensions under CGI/FastCGI. I tried everything I've found on the net, but nothing, nema ništa, rien, nada is working... I tried e.g.:
SetHandler cgi-script
ForceType application/cgi-php
et cetera...

I know it is possible to go extensionless with IIS 7.0 but there are other issues preventing me there. Anyone out there with a super and working solution?

Happy coding!
-------------------------------------------------------
The more I want something done, the less I call it work
- Richard Bach

jdMorgan

12:32 am on Nov 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The simplest approach may be to separate URL-paths from filenames, so that setting the MIME type by filename will work properly. You can use mod_rewrite to map extensionless URLs to files having the proper extensions for your purposes.

Jim

phranque

2:12 am on Nov 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], richard!

E_Flat

5:20 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



It seems like I'm stuck here...
I've managed to redirect extensionless files with mod_rewrite to files with extensions, like:

RewriteEngine On
RewriteBase /sites/test/rewrite
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^([a-z]*)$ $1.php [NC,L]

BUT, I don't want a redirect, I just want php to handle all files but can't do that with ForceType and FastCGI. I tried
DefaultType application/x-httpd-php in httpd.conf, but to no avail.

Any ideas will be very much appreciated! :-)

jdMorgan

5:30 pm on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Consider having your PHP script write the Content-Type response header.

Jim

E_Flat

6:45 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



No help there, alas.
This is the concept: In order to have one codebase serving several portals I use this in root files:
<?php
include("../application");
include(NEWSDIR . "/index");
?>
Putting header('Content-Type: application/cgi-php');
in the file doesn't work, the browser prints this as plain text. If it is impossible to map extensionless files to cgi-php I'd better go for adding extensions again and make them appear as extensionless. The idea about having every file extensionless is partly security, partly the "fanciness", and in the future I'll build Search Engine-Friendly URLs.