2

I use MAMP to develop sites. I have each site in it's own folder in the htdocs folder. I manage one site that I need to use ssi directives on, because the host doesn't allow php includes.

I've un-commented these lines in httpd.conf file:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

I added a .htaccess file in the htdocs folder with the following:

AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

On the site index page the include works using:

<!--#include file="top-nav.shtml" -->

But it does not work on files in any sub folder. I get this error:

[an error occurred while processing this directive]

3
  • 1
    I thought WAMP was Windows (+apache, MySQL, PHP) and MAMP was MacOSX, etc. Not that it likely matters for your question. Dec 19, 2010 at 1:12
  • The though by including both is that they are mostly the same environment, so I didn't want to exclude possible answers. Let me know if you think I should edit the post.
    – Jamie
    Dec 19, 2010 at 1:28
  • 1
    Your setup can't be both. If it matters, you should give the correct information. If it does not matter, you should not give any. So which is it; Windows or Mac? If it's Windows, don't say "It's MAMP", because it's not. Dec 19, 2010 at 1:32

2 Answers 2

1

Are you using the exact same include directive on all the sub-folder pages, too? If so, your problem seems clear: You aren't linking to the include file properly (unless you have that same file in every single directory on the site, which would sort of defeat the purpose)

Other than that, I'd want to know; what is the error you are getting on the server? Why do you think that SSI is not 'enabled' - especially considering it is working on one file, at least.

12
  • @Andrew I'm using: <!--#include file="./top-nav.html" --> in the sub folders. I think it's not working because the file only gets included on the index page and not on the index page one level deep. Not sure what error I am getting. Other than the one that prints out on the page"an error occurred while processing this directive". Which I think is a sign that ssi is "working" but...
    – Jamie
    Dec 19, 2010 at 1:26
  • @Jamie - Your include path above appears to include a period . at the beginning. Does that not denote the current path in includes, just as it does in the file system itself? Dec 19, 2010 at 1:30
  • @Jamie - Also... you really should get access to the actual error messages. debugging without them is going to lead you to an early grave. Dec 19, 2010 at 1:31
  • @Andrew Forgive me for not completely understanding your question, but I have the period in there to denote a relative path to the file I am trying to include.
    – Jamie
    Dec 19, 2010 at 1:35
  • @Jamie - The end result is exactly the same as just "top-nav.html"... it's looking in the same directory as the file is. Perhaps you meant to use double dots instead? "../top-nav.html" Dec 19, 2010 at 1:41
0

Not sure if this was resolved because the question is still open.

To add some clarification. use "file" when the file you're including resides in the same directory as the file that is referencing it. Use "virtual" when the file resides in a sub-directory.

Also, just my opinion, but it's good practice to put your includes in a directory of their own (usually named "inc" or "includes").

So for what you're trying to accomplish, you'd want to use...

<!--#include virtual="../inc/top-nav.html" -->

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .