Server side include no longer seems to be working - "[an error occurred while processing this directive]"

StackOverflow https://stackoverflow.com/questions/17087226

  •  31-05-2022
  •  | 
  •  

Question

We have a page that has been using a server side include for many years. Recently it stopped working. No changes have been made to the page

<!--#include virtual="..\..\includes\nav.include" -->

Near the bottom of a page called contact.html

The 'nav.include' page simply contains html for a navigation bar. No javascript. No server side scripting. Just html.

Is there some setting somewhere that needs to be set to make SSIs work in the way it is implemented here (including a file with an uncommon extension inside a html file)?

Was it helpful?

Solution

A solution that I discovered yesterday:

  1. I duplicated and renamed all my pages to .php (retained the original html files just in case!)
  2. I have replaced all the {<#include virtual="folder_name/file_name.ext" -->} with

        <?php include "folder_name/file_name.ext" ; ?> 
    

    with the appropriate number of dots and slashes depending upon where the pages are in my folder hierarchy. ( The {} above is to mark out the code only)

  3. Finally, I renamed the original index.html to some other name so that the index.php is picked up instead of the index.html

This seems to be working out - I am still testing out all the pages and links - a very tedious and time consuming exercise!

INCLUDES SYNTAX:

In a php file use

    <?php include "..//folder_name/file_name.ext" ; ?>

In an html file use

    <!--#include virtual="../folder_name/file_name.ext" -->

EXPERIMENT WITH NUMBER OF "..." AND NUMBER OF "///" IN THE ABOVE SYNTAX TO GET THE CORRECT COMBINATION!!!!

  1. For me, all my includes are small html files in a folder ABC which is directly under the webroot.
  2. For pages which are under sibling folders of ABC i.e. in other folders directly under webroot, "..//" is the number of dots and slashes that work.
  3. For pages which are directly in the webroot (i.e. not in any folder inside webroot), folder_name/file_name.ext without any dots or slashes has worked.
  4. I haven't had the time to check out the number of dots and dashes required for any other level in the hierarchy!

I hope this helps!

OTHER TIPS

Are you using GoDaddy? They did the same to my site, and I found on their forums someone that said to use include file instead of include virtual.

Just switched over to Godaddy servers and my SSI stopped working. I made a .txt file with the following:

AddHandler server-parsed .html

I uploaded it to the public html folder, then renamed it .htaccess, and everything started working.

I had too many files to convert all the extensions to PHP, so I had to find another answer, if at all possible.

For me, for a little while, exchanging include virtual to include file seemed to help, but then it broke again after a few days. I guess GoDaddy was not finishing monkeying around with the SSI configuration. o_O

The solution, as of tonight, was to convert all relative paths to absolute specification in regards to the site root. For example, I had to convert:

<!--#include virtual="..\..\includes\nav.html" -->

To:

<!--#include virtual="\includes\nav.html" -->

Using this approach, I was able to include HTML files inside other HTML files.

I discovered this on one of my pages that mixed absolute and relative path specification.

HTH

I've been seeing this problem frequently on my GoDaddy hosted site. I have to go into the Server configuration page, disable SSI, save the settings, then re-enable SSI and check "Use SSI on .HTM and .HTML files) and it starts working again.

The problem is on GoDaddy's side. For some reason, it's forgetting that it needs to parse SSI in files, until you turn off and turn on that option. Their Tier-2 support only suggested using Virtual instead of File on the Include command... which is preposterous, since not only does that not change a thing, the SSI includes work just fine most of the time... until it doesn't.

I'm also updating old .html pages to .php and replacing some of the with php include statements on all pages when some of the pages displayed [an error occurred while processing this directive].

The pages displaying the error also referenced an old .ssi file that wasn't even in the directory it pointed to. I deleted the old includes code to the non-existent .ssi file in those pages, and that fixed the error.

This error occurs when you have in your code html documentation like this

<!--#My awesome documentatacion-->

to fix it remove the #, like this

<!-- My awesome documentatacion-->
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top