0

I am having an issue with Apache 2.4 configuration with PHP5. I have got this:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi

  Action backButton /backButton.cgi
  AddHandler backButton .html .htm .php
</Directory>

It works for both .html and .htm files (i.e. backButton.cgi runs) but not for .php. I have tried everything I can find on the topic including just having .php (i.e AddHandler backButton .php).

If there is any extra information required please ask.

0

You have this set:

Action add-footer /script.pl
AddHandler add-footer .html .htm .php

Which seems odd to me. What is add-footer? What is script.pl? That seems to be an example from the Apache site that would cause requests for files with the html extension to trigger the launch of the footer.pl CGI script. Why would you need that?

Seems like that should be:

AddHandler php5-script php

So your whole Directory directive should be:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi .pl
  AddHandler php5-script php
</Directory>

EDIT: Since the original poster does want the add-footer functionality—now called backButton—it seems that this configuration would be the best way to handle; combine what I am doing above with with the original poster posted to begin with:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi
  AddHandler php5-script .php

  Action backButton /backButton.cgi
  AddHandler backButton .html .htm .php
</Directory>

ANOTHER EDIT: Seems like there was a typo the first time with me setting php instead of .php for AddHandler php5-script .php. But also, try this instead using application/x-httpd-php5 instead of php5-script:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi
  AddHandler application/x-httpd-php5 .php

  Action backButton /backButton.cgi
  AddHandler backButton .html .htm .php
</Directory>
  • Sorry, your right. I can see where you are coming from. This is indeed of the Apache site but I forgot to change it to my situation. The name add-footer in my case is backButton and /script.pl is /backButton.cgi (which is a bash script). I have edited the post above. What I am trying to do is to add some html content to every .html, .htm and .php page in a specific directory. The catch is I can't edit the pages. The solution above does exactly what I want for .html and .htm pages but not .php pages. The .php page itself runs fine but the extra content is not added. – JamesStewy May 5 '14 at 6:50
  • @JamesStewy Oh, okay. Then look at my latest edit. Combine what I am doing with what you are attempting to do & it should work. – JakeGould May 5 '14 at 14:08
  • So, I added AddHandler php5-script php to my example in the original post and it didn't make a difference. The php page loads but the html isn't added in. – JamesStewy May 6 '14 at 1:51
  • Hmmm… How about AddHandler application/x-httpd-php5 .php Look at my edit. Made a typo previously as well. – JakeGould May 6 '14 at 2:02
  • No difference... – JamesStewy May 6 '14 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.