SSI messes up my .shtml page!

SSI messes up my .shtml page!

Posted by: onewhoknows
Posted on: 2006-10-18 11:14:00

Hey everyone!

I tried to implement an additional script into a .shtml file! What happened when I added the <!--#include.... line is, that I only got a totally blank white page in Internet Explorer (source code shows a blank html page) and in Opera I even got some cryptic signs on the page. When I remove the line, everything's back to normal again! It's definitely not the php file I want to include or a wrong path, because if I make a .php page out of the shtml one and use the proper php command to include the file, it works!

I read that SSI's are enabled by default at Dreamhost, so this can't be the prob, I guess!? I also tried to turn off the mod_security module, with no result at all!

Anyone got an idea what could be the cause for this problem?

Greets

OneWhoKnows

Re: SSI messes up my .shtml page!

Posted by: scjessey
Posted on: 2006-10-18 11:50:00

Since you decided to use an expletive in the title of your post, I am going to make no effort to help you whatsoever.

Re: SSI messes up my .shtml page!

Posted by: onewhoknows
Posted on: 2006-10-18 12:01:00

OK, sorry - edited that. Didn't really think about that!

Re: SSI messes up my .shtml page!

Posted by: ardco
Posted on: 2006-10-18 12:27:00

> Since you decided to use an expletive in the title of your post, I am going to make no effort

Was thinking the same. Thanks for fixing it.

> blank white page in Internet Explorer

How's it look in Firefox? :-)

Similar works for me, at least in Firefox. :-) I vaguely recall having trouble previously, though, because I set a shtml page up to include another shtml partial page, which then included the php file.

Just tested, and including php file directly into shtml page works for me now.

Could it have to do with the php file permissions (executable)? Include virtual versus include file?

Care to show your shtml page include code?

What I Like About

Re: SSI messes up my .shtml page!

Posted by: onewhoknows
Posted on: 2006-10-18 12:42:00

Thanks for your reply ardco!

This is the code I used: <!- -#include virtual="script.php"- ->
(without the spaces between the -- of course)

I also tried it with "file" though, with the same result. I include the .php file of the script itself, not another .shtml file. I don't really think it has something to do with the file permission of the somescript.php file either because, like I said - I tried to include the file in php aswell.

Meaning, I renamed my index.shtml into index.php, and the using this command: <?PHP include("ttt-in.php"); ?> That way it works perfect!

Strange, isn't it?

Re: SSI messes up my .shtml page!

Posted by: scjessey
Posted on: 2006-10-18 13:26:00

In reply to:

This is the code I used: <!- -#include virtual="script.php"- ->
(without the spaces between the -- of course)

I also tried it with "file" though, with the same result. I include the .php file of the script itself, not another .shtml file. I don't really think it has something to do with the file permission of the somescript.php file either because, like I said - I tried to include the file in php aswell.

Meaning, I renamed my index.shtml into index.php, and the using this command: <?PHP include("ttt-in.php"); ?> That way it works perfect!


This is expected behavior. If you try to include a PHP script in an .shtml page, the PHP will not be interpreted. The .php extension is needed for this to work properly (although you may be able to edit an .htaccess file to get it to work).

Re: SSI messes up my .shtml page!

Posted by: kchrist
Posted on: 2006-10-18 14:24:00

Including PHP files via SSI should work fine. While I haven't used SSI in years, I've done exactly this many times in the past. I just tried it again on my DH account and it works fine.

My SSI file, ssi.shtml, contains nothing but:

<!--#include virtual="phpinfo.php"-->

And phpinfo.php, as you might guess, contains just:

<?php phpinfo(); ?>

Loading ssi.shtml in a browser displays the phpinfo() output.


Re: SSI messes up my .shtml page!

Posted by: scjessey
Posted on: 2006-10-18 14:32:00

In reply to:

Including PHP files via SSI should work fine.


Are you saying that .shtml files are handled by the PHP interpreter by default? Isn't that rather unusual? It certainly doesn't happen with .html files.

Re: SSI messes up my .shtml page!

Posted by: ardco
Posted on: 2006-10-18 14:37:00

>>> Just tested, and including php file directly into shtml page works for me now.

>> This is expected behavior. If you try to include a PHP script in an .shtml page, the PHP will not be interpreted. The .php extension is needed for this to work properly (although you may be able to edit an .htaccess file to get it to work).

php extension on included file, into a shtml file, works for me.


> Including PHP files via SSI should work fine.

Yep.

<!- -#include virtual="navbar.php"- ->

in test.shtml

displays navigation menu for me when test.shtml is loaded.

Maybe it's something about the php file you're trying to include?

What I Like About

Re: SSI messes up my .shtml page!

Posted by: kchrist
Posted on: 2006-10-18 15:33:00

No, .shtml files are still handled by mod_include, and you have to use SSI syntax in them. But if you include a PHP file from them, the PHP will be interpreted and the output will be inserted into the SSI file the same way static HTML is.

Re: SSI messes up my .shtml page!

Posted by: scjessey
Posted on: 2006-10-18 16:00:00

In reply to:

No, .shtml files are still handled by mod_include, and you have to use SSI syntax in them. But if you include a PHP file from them, the PHP will be interpreted and the output will be inserted into the SSI file the same way static HTML is.


Thanks, Dude. I didn't know it worked that way. Perhaps I'll add something to the wiki about it.

Re: SSI messes up my .shtml page!

Posted by: mranderso
Posted on: 2007-04-12 04:32:00

I've described the problem at
http://www.spm-sports.com/problem.html

incase any of the character get mangle.

SSI PHP seems to works fine with as long a browser doesn't send Accept-Encoding, but if it does, then the HEADER claims the file is encoded, but it doesn't look like it is.

(spaces intentionally added after < for this message, but are not in files)

= = = file:a.shtml = = =
< !--#include virtual="/b.php" -->

= = = file:b.php = = =
< ?php phpinfo(); ?>


-- curl sends without 'Accept-Encoding'
% curl -i http://www.spm-sports.com/a.shtml
-- works as expected, output is html output of phpinfo()


% curl -i -H "Accept-Encoding: gzip" http://www.spm-sports.com/a.shtml
-- response claims Content-Encoding of gzip in header
-- however, content for the most part seems human readable and uncompressed


% curl -H "Accept-Encoding: gzip" http://www.spm-sports.com/a.shtml | gunzip -
-- gunzip doesn't like encoding
-- gunzip: stdin: not in gzip format


-- demonstrates command should work and not generate "not in gzip formt" error
% curl -H "Accept-Encoding: gzip" http://diveintomark.org | gunzip -
-- HTML output as expected


So am I doing something wrong, or is the HTTP server not quite right?


(see also:http://jclark.org/weblog/2004/01/23/buganat/)
Edited by mranderso on 04/12/07 04:42 AM (server time).

Tags: shtmlssi