Jump to content

Recommended Posts

This is not the common "I don't know how to set Apache to handle PHP in an HTML file" type of issue. That works. AddHandler application/x-httpd-php5 .html

 

I don't usually configure things like this, but I'm working with an existing site and I don't really want to make a change to URLs here. (If all else fails I'll just add a rewrite in .htaccess.)

 

Here are two examples of what's happening:

  • I have some files that are PHP, and they include HTML files. The HTML partial files sometimes have PHP code. That code works.
  • If I simply try to access somefile.html, and that file includes only PHP code, the raw PHP code will be displayed, instead of being executed as code.

Why would that first bullet point be true if that second one is false?

 

Again, I wouldn't have structured things how they are structured now, if starting from scratch. I'll probably do something a little bit different but I would like to know, as general knowledge, why the current setup would fail. Does it matter that in one example a PHP code is being called first, where as the other example calls a .html file directly (as opposed to being included)?

 

 

Sounds like it is just a common server-configuration problem.

 

If you have a PHP file includeing other files then those files will be parsed for PHP code regardless of their extension or the server's configuration. That is what the include function does, it includes another file as PHP code.

 

Accessing a .html file directly and having the PHP code not be executed means that your setup is not properly configured to apply PHP to .html files. Go over your configuration again and verify it is correct and being loaded by apache.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.