cancel
Showing results for 
Search instead for 
Did you mean: 

Couple of php issues - any suggestions?

Anteaus
Grafter
Posts: 64
Thanks: 1
Registered: ‎02-08-2007

Couple of php issues - any suggestions?

1: I want .htm or .html files to execute as php scripts. There are normally a couple of ways of doing this in .htaccess but none seem to work on pn ccgi space.
Typically:
 AddHandler php-script .htm   
Or
<FilesMatch "\.(htm|html|php)$">
 SetHandler application/x-httpd-php
</FilesMatch>
Or
<Files "*.htm">
 SetHandler application/x-httpd-php
</Files>
but none seem to work.
2: If I have an auto_prepend_file = "path/file.php" command in php.ini, the server reports that it cannot find the file to prepend, even though it then proceeds to report the correct location of the file.  However, if I include the same file using a standard php include command with exactly the same path, that works.  I've tried a relative path, path from webspace root, path from filesystem root, but none work.  Any idea what path information the server is looking for?
UPDATE: OK, found answer to #2, pn servers don't like quotes around the filename. Still looking for solution to #1 though.
5 REPLIES 5
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Couple of php issues - any suggestions?

AddHandler cgi-script .htm

will get your .htm files handled as scripts, but I think binfmt for php will only know about the .php extension, so you would need to add shebang lines to use /usr/bin/php5-cgi
Or you could use a rewrite. Something like:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.htm$ $1.php

Gabe
Anteaus
Grafter
Posts: 64
Thanks: 1
Registered: ‎02-08-2007

Re: Couple of php issues - any suggestions?

Unfortunately, AddHandler cgi-script .htm causes a 500 error, even if it is the only command in .htaccess.
Meanwhile rewriting would not achieve the desired result since all of the files would have to be renamed. The objective is to have scripting enabled in standard files.
Thx for reply anyway.
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Couple of php issues - any suggestions?

Quote from: Anteaus
AddHandler cgi-script .htm causes a 500 error

Presumably you didn't add a shebang line.
Quote
all of the files would have to be renamed

That's easily scripted, though the !-f allows a mix. Those are the only options I can think of with the ccgi set-up.
Gabe
Anteaus
Grafter
Posts: 64
Thanks: 1
Registered: ‎02-08-2007

Re: Couple of php issues - any suggestions?

Quote
Presumably you didn't add a shebang line.

If that has to be done to every page, then it's going to cause major issues, especially for any new pages built with software. Probably easier toaccept the workload of bulk renaming and bulk link-replacement than having a situation where no new page will work until doctored.
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Couple of php issues - any suggestions?

Or you could use a wrapper script.
Gabe