Forum Moderators: phranque
The message follows.
My web host's PHP doesn't provide curl, so I want to run .php files thru my own PHP parser. However, I don't want to rename all the .php files into .cgi files and add some #!/path/to/php as the first line.Is it possible to change the default parser, somehow? So far, I've only tried playing with .htaccess file.
First I wrote
Action php-parser /path/to/php
AddType php-parser .php
and when I tried to access phpinfo.php I got the error message "The requested URL /path/to/php/phpinfo.php was not found on this server"Then I tried
Action application/x-httpd-php /path/to/php
but that didn't do any good. phpinfo.php was still parsed by my host's PHP.So the next shot was
Action application/x-httpd-php /path/to/php
AddType application/x-httpd-php php
which yielded the same error message as in the first case. So I figured application/x-httpd-php was not valid and tried onlyAddType application/x-httpd-php foo
This way phpinfo.foo was parsed, as well as phpinfo.php. I cleared the .htaccess file one more time and typedAction php-parser /path/to/php
AddType php-parser php
but that yielded the notorious error message "The requested URL /path/to/php/phpinfo.php was not found on this server".
Try the RemoveType and/or the RemoveHandler directives in your htaccess file. Read the corresponding part of the Apache documentation carefully, there is some caveat when you use them.
Try ScriptAlias and put the directory where your php parser is into the url, and use this aliased path instead:
ScriptAlias /myparser/ /path/to/php
Action application/x-httpd-php /myparser/php The last suggestion might be is to use the custom parser as a cgi binary from a php script, send the request via stdin and receive the parsed output from stdout and voila. Dirty and not nice at all, but could be that this is the only way if you don't have access to the Apache config.
Good luck
I tried to apply RemoveType and RemoveHandler but they didn't change a thing.
Sadly, I can only use htaccess, so ScriptAlias cannot be used.
Apparently my last shot was
AddHandler my-handler .foo
Action my-handler /home/customers/logonetshop/php/bin/php.cgi
which gave me the Not found error ("The requested URL /path/to/php/bin/php.cgi/phpinfo.foo was not found on this server").
(The fact the it didn't work was kind of funny, because that was taken almost directly from an Apache manual example.) The /path/to/php/bin/php.cgi file contained only one line:
#!/path/to/php/bin/php
It read somewhere in the manual that Actions should be cgi-scripts. So I figured that would do the trick. Well, it didn't.
Augh.. I guess I'll just have to start renaming the .php files into .cgi and carry on that way..
Thanks for the help, though.
Action php-parser /path/to/php
AddType php-parser .php
That is, phpinfo.php is located at /path/to/public_html/relative/path/to/phpinfo.php and I get the 404 error ("URL /path/to/php/relative/path/to/phpinfo.php not found").
I wouldn't know whether the AddHandler or AddType is the way to go, as neither of them works for me.