Jump to content

Recommended Posts

Posted

Greetings,

 

Ok, I know this is proabably going to be something really stupid that I am doing wrong. I am trying to create a "header" for a group of pages using the SSI "Include" directive. (I have a test setup at www.gregorycain.net/ssitest).

 

The code for the 'index.html' page is:

 

<html>

<head>

<title>test of ssi</title>

</head>

<body>

This is the doc

<p>

<!--#include virtual="./ssi.txt"-->

</body>

</html>

 

The code for the included 'ssi.txt' page is:

 

<p>

This is the include.

 

When I go to this page, I get the "This is the doc" text but not the "This is the include." text.

 

I've tried using "#include file" instead of "#include virtual" and excluding the "./" at the beginning of the file reference. Always comes back the same way.

 

I've also placed a .htaccess in the folder with the following:

 

Options +Includes

 

Any help would be greatly appreciated!

 

Thanks

 

Greg

Posted

I'm not sure but your sample reads like this:

 

<!--#include virtual="./ssi.txt"-->

 

Have you tried it this way?

 

<!--#include virtual="/ssi.txt" -->

 

Note: I took off the "." period and added a space before the -->

 

You may want to read over this post as well where you can use PHP includes to accomplish what you are trying to do.

 

http://www.totalchoicehosting.com/forums/i...5&st=0&p=132569

Posted
if the include is in the same folder as the page

change

<!--#include virtual="./ssi.txt"-->

to

<!--#include virtual="ssi.txt"-->

 

Have tried all of these:

 

"ssi.txt"

"/ssi.txt"

"./ssi.txt"

 

all with the same result.

 

Any other ideas?

 

Thanks again.

 

Greg

Posted (edited)
I have a test setup at www.gregorycain.net/ssitest.

 

The code for the 'index.html' page is:

 

<html>

<head>

<title>test of ssi</title>

</head>

<body>

This is the doc

<p>

<!--#include virtual="./ssi.txt"-->

</body>

</html>

That is not what I'm seeing at www.gregorycain.net/ssitest/index.html - I see a totally different page that does not appear to have an SSI include directive. Never mind - the page was changed in the time it took me to compose this post.

 

Also, your page would need to have a .shtml extension in order for SSI includes to be processed.

Edited by TCH-David
Posted
That is not what I'm seeing at www.gregorycain.net/ssitest/index.html - I see a totally different page that does not appear to have an SSI include directive.

 

Also, your page would need to have a .shtml extension in order for SSI includes to be processed.

 

 

Ok, my apologies - I temporarily uploaded a different page to that directory. I found what the problem was though. Putting the followin in .htaccess fixed it:

 

Options Indexes FollowSymLinks Includes

AddType application/x-httpd-CGI .CGI

AddType text/x-server-parsed-html .html

 

Thanks very much for your help!

 

Greg

  • 2 weeks later...
Posted (edited)

I am having somewhat of a similar problem. Whenever I call up the page, i get an error saying "[an error occurred while processing this directive]"

 

I tried doing as one poster did by including the lines in the .htaccess file, but it seems to be invisible. I can see the ,htaccess files thru my ftp app in my main direcory and subdirectory on the server, but when I download .htaccess to my computer directory, it isnt visible. I used BBEdit to "open hidden" then edited the file and then uploaded it back to the server thru Dreanweaver but i still get the same "[an error occurred while processing this directive]" msg.

 

First, I want to start by asking how do I even make the .htaccess file visible to me? I think once I can find a solution to this problem, I can figure out how to get my SSI to finally run.

 

Thank you in advance for your input <_<

 

Update:

 

I fear I may have made matters worse :blink:

After editing my .htaccess files, I now get the following when I call up my test page:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

</head>

 

<body>

[an error occurred while processing this directive]

</body>

</html>

 

Oh Gods of web design, have I sinned?

Edited by Xantith
Posted

Welcome to the forums Xantith <_>

 

Maybe it would be easier to edit the .htaccess file right on the server. Use the File manager in cPanel. Most FTP clients will not show hidden files by default.

 

Also the .htaccess file is a text file and must be uploaded to the server in ASCII mode.

 

I make my changes using the editor in the file manager.

Posted
Welcome to the forums Xantith  <_<

 

Maybe it would be easier to edit the .htaccess file right on the server.  Use the File manager in cPanel.  Most FTP clients will not show hidden files by default.

 

Also the .htaccess file is a text file and must be uploaded to the server in ASCII mode.

 

I make my changes using the editor in the file manager.

 

 

OK, using cPanel to edit/upload my files was something I wasnt aware of, thanks for the tip.

However, i took your advice and edited the .htaccess files thru cpanel and added the following lines:

 

Options Indexes FollowSymLinks Includes

AddType application/x-httpd-CGI .CGI

AddType text/x-server-parsed-html .html

AddType text/x-server-parsed-html .shtml

 

I still get the same errors.

I am a bit short on time right now, so when I have free time later today I will tackle this problem by starting fresh...creating an .htaccess file and uploading it thru cPanel. Thanks for your help so far...I should have waited to address this problem while I had time to see it through, but I will keep you posted on my efforts.

Posted

Welcome to the forums Xantith <_<

 

before you just replace the .htaccess file on your site

you may want to see what else is in it by editing it in cpanels filemanager.

 

For me I would rather use php includes instead of ssi

 

I add

AddHandler application/x-httpd-php .htm .html .shtml

 

to the first line in the .htaccess file

 

then in my html pages I can use something like

 

<?php

include $_SERVER['DOCUMENT_ROOT']."/menu.php";

?>

Posted
Welcome to the forums Xantith :D

 

before you just replace the .htaccess file on your site

you may want to see what else is in it by editing it in cpanels filemanager.

 

For me I would rather  use php includes instead of ssi

 

I add

AddHandler application/x-httpd-php .htm .html .shtml

 

to the first line in the .htaccess file

 

then in my html pages I can use something like

 

<?php

include $_SERVER['DOCUMENT_ROOT']."/menu.php";

?>

 

 

Thank you for the warm welcome. :P

 

When I first looked at my htaccess file, there was nothing in it at all. Also, I know absolutely nothing concerning php so I hope you can spare a bit of patience.

 

I am a bit confused here as far as what is required in the above statement, and what are variables(?) Is $_SERVER exactly what I use, or is that the name of my server? next along the line...'DOCUMENT_ROOT' Is it safe to assume that is the path to the file I want displayed? and are the quotes (') mandatory? Last but not least menu.php must be the name of the file I want to use?

 

Sorry to be a pain here, what I am trying to accomplish is to generate the news file from my ikonboard into my homepage. It sound pretty easy at first, but its turning into a bit of a mess for me.

Posted
I used BBEdit to "open hidden" then edited the file and then uploaded it back to the server thru Dreanweaver but i still get the same "[an error occurred while processing this directive]" msg.

 

Unless things have changed since I fixed my version of Dreamweaver, DW uploads .htaccess files in the wrong mode, which is why it wouldn't work when uploaded back on the server--the file gets corrupted along the way or something.

 

To fix it, you have to edit the .config files for DW, I think, and set .htaccess files to the correct mode. I forget the exact details--it's been a while--but I found that fix here, searching "dreamweaver .htaccess".

Posted
Welcome to the forums Xantith :P

 

before you just replace the .htaccess file on your site

you may want to see what else is in it by editing it in cpanels filemanager.

 

For me I would rather  use php includes instead of ssi

 

I add

AddHandler application/x-httpd-php .htm .html .shtml

 

to the first line in the .htaccess file

 

then in my html pages I can use something like

 

<?php

include $_SERVER['DOCUMENT_ROOT']."/menu.php";

?>

 

 

Ok, I finally got it...thanks to Don enlightening me on PHP. Like I mentioned, I knew absolutely zero when it came to php, but after sleuthing thru Dreamweaver, I basically created a fresh php page then called the file I needed....worked like a charm. My first PHP page!

 

Thank you all for the help and responses, you guys are the best!

Posted

:) you are welcome ;)

 

what the lines mean

<?php

include $_SERVER['DOCUMENT_ROOT']."/menu.php";

?>

 

the first switches to php

<?php

the next includes a file referencing the root folder (your public_html folder)

and looks for the file menu.php

 

you can also put the includes in a folder

include $_SERVER['DOCUMENT_ROOT']."/includes/menu.php";

so this will work no matter what folder the page doing the include is in

 

the last line

?>

switches out of php

 

next you might try seperating your page into a common header and footer to make a consistant page that is easy to update

 

a template might look like this

><?php
// add header
include $_SERVER['DOCUMENT_ROOT']."/header.php";
// begin main content
?>

<p>Content</p>

<?php
// end main content 
// add footer file 
include $_SERVER['DOCUMENT_ROOT']."/footer.php";
?>

  • 3 years later...
Posted (edited)
Ok, my apologies - I temporarily uploaded a different page to that directory. I found what the problem was though. Putting the followin in .htaccess fixed it:

 

Options Indexes FollowSymLinks Includes

AddType application/x-httpd-CGI .CGI

AddType text/x-server-parsed-html .html

 

Thanks very much for your help!

 

Greg

 

 

Thank you! Thank you! Thank you!

 

I've been searching through these forum postings for going on 3 days now and you were the only one I've found that posted the solution. This also fixed my problem and I'm now able to get the marching band website into some new and VERY COOL tools thanks to TCH!

 

-JoDee

Edited by tjmckenney
Posted

Welcome, JoDee! :)

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...