cancel
Showing results for 
Search instead for 
Did you mean: 

#include virtual not working after CGI platform change

Mattallyc
Newbie
Posts: 8
Registered: ‎25-10-2010

#include virtual not working after CGI platform change

Hi All,
Since the change to the new CGI platform I can't get #include virtual tags to work.
All of my pages include a link to a footer page:
<!--#include virtual="/includes/footer.html" -->
The page opens fine if I address it directly, and if I copy and paste the html from the footer page in place of the #include tag it works.
I've tried removing the first slash in the path and even moved the footer.html file into the same folder as the page that calls it and removing the forward slashes and folder name from the path but it still won't include the file.
This all worked before the CGI change.
Am I doing something wrong or is this a feature of the new CGI platform?
Thanks in advance,
Matt.
18 REPLIES 18
Mattallyc
Newbie
Posts: 8
Registered: ‎25-10-2010

Re: #include virtual not working after CGI platform change

Is anyone else using #include and is it working?
Or is there a way for me to check an error log so I can dig a bit deeper into this?
I'm assuming that I must have the path right as on one page I link to a pdf form which is also in the /includes directory and that works fine...
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: #include virtual not working after CGI platform change

Yes, #include works on the Hostopia server, though I have them only in a small number of files with extension .shtml .
In your case I assume you want the server to parse all .html files. Have you included

AddHandler server-parsed .html

in .htaccess?
The following HTML

<p>The date and time are inserted using an SSI tag<br />
<!--#echo var="DATE_LOCAL" --></p>

provides an alternative way to check if SSI tags are working.
David
David
Mattallyc
Newbie
Posts: 8
Registered: ‎25-10-2010

Re: #include virtual not working after CGI platform change

Thankyou David!
That was it - I added the line into .htaccess, refreshed the page and bingo there it was.
Thanks for your help, much appreciated.
Regards,
Matt.
decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: #include virtual not working after CGI platform change

Hmm...
I appear to have a similar problem, but my .htaccess looks to be OK:
AddType text/html .shtml
AddHandler server-parsed .shtml
DirectoryIndex index.shtml
The website's index.shtml page loads fine.
This page has an SSI include which looks like:
<!--#include virtual="sometext.inc" -->
which worked (on PAYH) but now fails with 'an error occurred while processing this directive'
sometext.inc has permissions 644
I noticed however that if I try to view sometext.inc directly via the browser, I get a 403 "You don't have permission to access /sometext.inc on this server."
A red herring.?
Spraxyt's test:
<p>The date and time are inserted using an SSI tag<br />
<!--#echo var="DATE_LOCAL" --></p>
works.
Any ideas pls anyone?
Zen from May 17. PN Business account from 2004 - 2017
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: #include virtual not working after CGI platform change

I wonder if the 403 is due to the file being a .inc? I know that include.txt and include.shtml can be accessed directly in Firefox.
I use include file=... rather than include virtual= and that works with .txt and .shtml files; examples
<p><!--#include file="include.txt" --></p>
<p><!--#include file="include.shtml" --></p>
... but the OP said include virtual=... worked.
An SSI directive nested within include.shtml works too (but not if within include.txt - because that is not marked server-parsed I expect).
David
decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: #include virtual not working after CGI platform change

Many thanks Spraxyt
I strongly suspect you are right - that Hostopia's version of Apache with my usual .htaccess directives is unwilling to #include files which are not .txt or .html, and that Hostopia's Apache config is different from both PAYH and PN Home pages in this respect.
I am about to check Apache's documentation on 'directives' and see if additional ones need inserting in .htaccess for file types other than .txt and .html 
Zen from May 17. PN Business account from 2004 - 2017
decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: #include virtual not working after CGI platform change

Further to my last post, I have done some tests.
On Hostopia's Apache, SSI #include will NOT include files of filetype .inc  (As Spraxyt says, .txt and .html are fine)
PN Home pages and PAYH servers, #include WILL include files of filetype .inc
Using an AddType text/html .shtml  .inc in .htaccess makes no difference
Using .inc appears valid according to Apache documentation. So is this a known server setup problem? And is there an easy solution?

Zen from May 17. PN Business account from 2004 - 2017
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: #include virtual not working after CGI platform change

The Apache 'how to' guide for SSI says both of the following directives are needed to make SSI work. I've never added the latter but - long shot - you could try it with .inc
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
David
decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: #include virtual not working after CGI platform change

Tnx Spraxyt
I tried inserting a .inc in just about every .htaccess directive but it makes not a jot of difference. I also tried different browsers (although this should make no difference at all since parsing is an Apache function).
But - logically - if SSI is working at all (which it is clearly is), it is Apache's (and only Apache's) job to decide from the  zillions of file extensions possible which ones are acceptable.
Setup fudges apart, Apache should looking at directives its own Configuration files and then in .htaccess (or .htaccess'es is there is a hierarchy of them - I only have one!). And its Configuration files directives should be telling it what directives in .htaccess should be acted upon and which ignored. 
All I know is that .inc was allowable in CCGI and PAYH Apaches but not in Hostopia's.
I have worked around this at present with some code changes and by moving some code outside of PN/Hostopia (the .inc files are written by PHP but SSI-included in Home Pages pages, so it is not just a matter of renaming a file or two).

There may, of course, be a wonderfully simple .htaccess directive such as:
AddHostopiaFudge .inc
This probably needs Bob or someone from Hostopia to follow up and let us know what is allowed by their Apache setup.
Zen from May 17. PN Business account from 2004 - 2017
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: #include virtual not working after CGI platform change

I think .inc files traditionally contain configuration settings that normally are not intended to be served to browsers. So the server configuration is set to deny that. In this context SSI probably counts as browsing. Apache as an application serves files but what files/file types it can serve is set in its local configuration, not by the developers.
Part of that configuration restricts where particular classes of settings can be changed and I guess allowing .inc files to be served is disallowed via .htaccess.
David
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: #include virtual not working after CGI platform change

@decomplexity, If you can chuck a couple of simple test files that exhibit the problem into a directory on your webspace and open a support ticket then I'll raise the issue with Hostopia.
Give me a nudge here though once you've done this.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: #include virtual not working after CGI platform change

Bob - a nudge as requested : see ticket #86995860
Zen from May 17. PN Business account from 2004 - 2017
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: #include virtual not working after CGI platform change

Thanks, on it now.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: #include virtual not working after CGI platform change

Quote from: decomplexity
On Hostopia's Apache, SSI #include will NOT include files of filetype .inc  (As Spraxyt says, .txt and .html are fine)

I've now had confirmation from Hopstopia's Security Team that the inclusion of .inc files is not permitted as a security safeguard. As we've already determined, other commonly used SSI file extensions are allowed e.g. asp, txt, cgi etc.
I don't expect there's a workaround other than to use a different file type/extension.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵