1

I have a CGI script in the server called script.cgi and I have added the following code to the domain vhost:

   Action add-footer /cgi-bin/script.cgi 
   AddHandler add-footer .htm .html 

I have change it to:

   Action add-footer /cgi-bin/script.cgi 
   AddHandler add-footer .htm .html .php

If the page is HTML the code will run but if the page is PHP the code will not run. Is there any code I need to add to the vhost so that PHP files can run this script?

****EDITED:****

I want to "inject" an HTML code in every possible page of the server this includes HTML and PHP files.

The code only works for html files and I don't know why.

1 Answer 1

1

Sorry, but I don't understand CGI is not PHP, it is Perl and this requires Perl/CGI support not PHP. PHP scripts have .php extensions, not .cgi/.fcgi.

Maybe I missed something here. Can you further clarify question. Like what web server you're using? Is this PHP code embedded into .cgi script or?

***** EDIT *****

So you can look at CGI as an interface, in your case interface that uses Perl. You cannot intermix PHP in CGI environment, but you can modify the .cgi script to make external call towards .php script.

This can be done in few ways:

  1. system() command
  2. exec() command
  3. using handles
  4. using backticks

The HTML "works" normally because HTML is interpreted by the browser and PHP is server-side language which must be executed in adequate environment.

I propose further reading on how Perl executes external scripts:

http://www.perlhowto.com/executing_external_commands

2
  • For question please use the COMMENTS section and not the ANSWER section. May 30, 2014 at 21:01
  • I have edited the question... May 30, 2014 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .