Welcome to WebmasterWorld Guest from 54.204.106.194

Forum Moderators: incrediBILL

Message Too Old, No Replies

Server Side Includes

     
5:38 pm on Apr 12, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 8, 2006
posts:1232
votes: 0


I am using a hosted server, and trying to set up some includes on my site... i have done this with PHP on a linux server but not with HTML on a Win server..

Server: Win 2003 Enterprise Server

CGI Active

Pages are HTML.

i created an includes folder.

i created: nav.shtml

Per my server notes in the Cpanel it says: "Required SSI filename extensions: .shtml"

in my index.html page i used the line:
<!--#include virtual="includes/nav.shtml"-->

and other various tries... what am i missing?

can i not use html pages, do they have to be .asp pages to call the include?
5:46 pm on Apr 12, 2010 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5646
votes: 66


in my index.html page

I think you need to use index.shtml

The .shtml alerts your web server to parse that file differently than static HTML files.

Unless you have another include in the included file, you probably want to use:
<!--#include virtual="includes/nav.html"-->
7:11 am on Apr 13, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts:1199
votes: 0


Yes, you have the html/shtml backwards. .shtml is for the calling page, .html is for the called page. Actually, the called page can have whatever extension you want. I typically use .ssi, for example.

Also, if you put this code into your .htaccess file, then it doesn't matter whether your pages end with .shtml or .html:

AddHandler server-parsed .html

All of the above works for Apache web servers, but I assume it'll work for Windows, too.
6:27 pm on Apr 13, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


The included file can be pretty much anything. <strong>However, the space before --> is extremely important.</strong>


<!--#include virtual="includes/nav.html" --> (in this case)

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

<img src="<!--#include virtual="/images/some-image.gif" -->" alt="img">

<!--#include virtual="/cgi-bin/some-script.cgi" -->
12:37 am on Apr 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts:1199
votes: 0


What's important about the space before the "-->"? I've never included that space, and I've never had any problems...that I know of.
6:58 pm on Apr 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


I can't even remember, all I recall is battling it one day and the space was what fixed it. One of those things you learn and forget about **why.**

Closest I found was this [w3u.net], (mods, nix the link if inappropriate) in reference to using echo:

When you forget to leave a space before the closing SSI command HTML tag (-->), or when you add a space between the hash sign (#) and the SSI command (<!--# echo), nothing works, and you get that silly and ever-so-helpful error message ["an error occurred while processing this directive"].


If you note all the examples [httpd.apache.org], they have spaces.
3:49 pm on Apr 16, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts:1199
votes: 0


Okay. But it's worked for me 100% of the time without the space, for years, so I think I'll likely keep doing it that way.
1:37 am on Apr 17, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


The space may be optional on some systems and mandatory on others. Since it is harmless, it's probably best to include it.

Kaled.
4:20 pm on Apr 17, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


kaled nails it -- there are lots of technical areas where many systems now recover from common errors, but it's still best not to make them in the first place.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members