|Include Virtual works on some, but not others|
This is driving me crazy. I would appreciate any help. We have an older hand-crafted web site with many pages using SSI include virtual, and using the Xbithack instead of naming the files .shtml.
On our old server, Apache 1.3, the pages worked well. But we recently moved to a new box with Debian Squeeze and Apache 2.2. Now things are in a state where some of the includes on a page work, and some don't.
For example, on our home page, we have:
This works OK as an ad banner rotation system. But on the same page we have:
<!--#include virtual="rss2html.php?XMLFILE=http://outside_domain.com/path/atom.xml&TEMPLATE=http://example.com/sample-template.html&MAXITEMS=4" -->
This is not working. Instead the page displays "[an error occurred while processing this directive]"
We know the file rss2html.php works when invoked by itself outside of being embedded in an html page.
Below are our Vhost and .htaccess files in the top docroot directory.
|<VirtualHost *:80> |
Options Indexes FollowSymLinks MultiViews
allow from all
Options Indexes FollowSymLinks Includes ExecCGI
allow from all
# omitting cgi-related directives
# omitting logging-related directives
in the directory /home/domainname/public_html, the .htaccess file is:
|# Set some options. |
# Customized error messages.
ErrorDocument 404 /index.html
# Set the default handler.
DirectoryIndex index.html index.php
# AuthUserFile /dev/null
# AuthGroupFile /dev/null
# XBitHack Full
|<!--#include virtual="rss2html.php?XMLFILE=http://outside_domain.com/path/atom.xml&TEMPLATE=http://example.com/sample-template.html&MAXITEMS=4" --> |
Any difference if you omit the querystring? Is the PHP file being parsed for SSIs? Are PHP files the problem? Only reason I ask is that I was having a play with SSIs a few weeks back but it all started to go very wrong when I began parsing PHP files for SSIs as well, but I didn't pursue it so I'm not really sure what the problem was! :/
It works if I take it our of the html page and run the .php file on it's own (with the query strings). The log files say the php file is not being parsed. There are perl cgi files on the same page which do work. I'd say it was the php file ... except that they all worked before in the previous box, under Apache 1.3 and PHP 4.3.
Adding the following line may work on your server:
Addhandler application/x-httpd-php .html
You can replace or add extra handlers depending on what type of page the php code will be executed on.
Thanks Pender and Key_Master for the replies, and I'll certainly keep the Addhandler tip in mind. From another source, I was able to find a fix, at lease one that works in the short term.
I didn't really consider this as I had dealt with this issue many years ago (in the 90's) and thought I had gotten it right for any instance of include virtual (or for "exec cgi" for that matter).
On the php comment, the invocation is simple "rss2html.php" with additional arguments. That's a relative URL.
I changed it to an absolute from the docroot by making it:
and keeping the two arguments. Strangely, the arguments are still URL's.
On the old server, the php file invocation worked as a URL. Over the years I've found no general rule of thumb on whether to use URLs or addresses either from root or docroot. It seems to work sometimes one way and other times the other way.
|I changed it to an absolute from the docroot by making it: |
Isn't this relative to the current working directory (.)? If you omitted the dot prefix then it would be 'absolute' (or root-relative) to the docroot. "rss2html.php" on the other hand is relative to the current document. Is it possible that the current working directory and the location of the document being parsed are different?
In this case, the html file being parsed is the web site's home page and it exists as /home/username/public_html/index.html which is docroot. The file rss2html.php is in the same directory, so it would be /home/username/public_html/rss2html.php. For whatever reason, it's now working with the ".\" added, and fails to work with the dot-slash.