Forum Moderators: phranque

Message Too Old, No Replies

When parsing SSI's, PHP files don't work

         

damlag

8:46 pm on Dec 12, 2004 (gmt 0)

10+ Year Member



Could give me a hand here...

I put this in .htaccess file:

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

I want to parse all html files for SSI's as long as all my files are .HTML and include SSI's.

Well, almost all... There's one file PHP, which makes all the trouble. When I put the code above, that PHP file doesn't process at all. When I add .php next to AddType and AddHandler, my PHP file shows the actual code instead of processing it.

Is there some simple workaraound? Maybe I use wrong commands?

thx.

coopster

6:17 pm on Dec 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Which version of Apache are you running?

Apache 1.3 [httpd.apache.org]
Apache 2.0 [httpd.apache.org]

damlag

6:35 pm on Dec 13, 2004 (gmt 0)

10+ Year Member



Apache version is 1.3.32

coopster

1:58 am on Dec 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




I want to parse all html files for SSI's as long as all my files are .HTML and include SSI's.

Well, then I'd follow the first link and listen to the developers recommendation...


A brief comment about what not to do. You'll occasionally see people recommending that you just tell Apache to parse all .html files for SSI, so that you don't have to mess with .shtml file names. These folks have perhaps not heard about XBitHack. The thing to keep in mind is that, by doing this, you're requiring that Apache read through every single file that it sends out to clients, even if they don't contain any SSI directives. This can slow things down quite a bit, and is not a good idea.

damlag

6:48 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



So the only way is XBitHack?

Basically there is no point using XBitHack, because all my files have includes and end with .html extention. It's just one PHP script that makes all the problem.

So isn't there any way to make that PHP script work correctly using simple parsing (not XbitHack)?

Thx.

coopster

7:23 pm on Dec 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have your tried adding it to the AddHandler directive?
Options Indexes FollowSymLinks Includes 
AddType text/html .html
AddHandler [httpd.apache.org] server-parsed .html .php
Remember that this mapping is added to any already in force, overriding any mappings that already exist for the same extension. Make sure you test.

damlag

10:29 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



Yep,
I tried that. Then the browser simply wants to download the script instead of processing it.

damlag

11:11 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



Woooowwww Coopster!

I just added this:
------------------------------
Options +Includes
AddType text/html .html
AddHandler server-parsed .html
------------------------------

Instead of this:

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

And everything worked just great.
All html files that have includes are
normally parsed and PHP script also processes
perfectly. No problems.

Can You explain me what has happened?

coopster

2:46 am on Dec 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




Normally, if multiple Options could apply to a directory, then the most specific one is taken complete; the options are not merged. However if all the options on the Options directive are preceded by a + or - symbol, the options are merged. Any options preceded by a + are added to the options currently in force, and any options preceded by a - are removed from the options currently in force.

Resource:
Options [httpd.apache.org]

Another discussion on SSI and PHP that may be of interest [webmasterworld.com].

damlag

5:00 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



Coopster, thanx a lot, really man...

I see You're a pro in SSI and can answer almost any question. Last one I'd like to ask is this:

---------------------------------------------
"You'll occasionally see people recommending that you just tell Apache to parse all .html files for SSI, so that you don't have to mess with .shtml file names. These folks have perhaps not heard about XBitHack. The thing to keep in mind is that, by doing this, you're requiring that Apache read through every single file that it sends out to clients, even if they don't contain any SSI directives. This can slow things down quite a bit, and is not a good idea."
---------------------------------------------

But if ALL my files contain Includes, then there's no difference if I use XBitHack or simple parsing, right?

coopster

9:02 pm on Dec 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You're welcome and thanks for the compliment. I wouldn't go so far as to call myself an Apache SSI pro, though ;)

I would venture to guess that you are correct in that if you are running server-side includes on every page then it wouldn't matter if you are using the XBitHack or AddHandler (or AddOutputFilter, if on Apache2). But, as I said, that is a guess at best. To know for sure I guess you would have to perform some server tests or perhaps look into the development source code.

damlag

10:51 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



That's exactly what I'm gonna do. I'll test both methods and see if there's some kind of lag or not.

Thanx again man,
Happy Hollidays!