Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't my SSI work?

I am having problems with passing query params into SSI include from within my zend framework application.

I am trying to include a PHP file inside another PHP:

<!--#include virtual='/ssi/test.php?x=hello' -->

This executes properly, if my hellotest.php (which contains the above line) resides in my document root.

If, however I do the same thing from within my template.phtml (not /public_html/hellotest.php anymore) (I am using Zend Framework for this project) , the test.php is called and executed without any query parameters (in this case x=hello). No query parameters are passed into test.php from withitn my zend_framework templates .

Does this have anything to do with the way zend framework uses .htaccess ? Here is a copy of my .htaccess files (in web root: /public_html/.htaccess)



SetEnv APPLICATION_ENV development

AddOutputFilter INCLUDES .php

RewriteEngine On

RewriteRule (.*/?)(.*css)$ combine.php?type=css&files=$1$2 [NC,L]
RewriteRule (.*/?)(.*js)$ combine.php?type=js&files=$1$2 [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

EDIT: I've recently found out, that it will pass parameters into the SSI taken from URL . So if in my browser I type http://www.test.com/controller/action?param1=something , it will actually pass param1 into the SSI , but it will totally ignore the params I have on the SSI line. ... anyone has experience with this ?

EDIT2 - in response to Tim Fountain: correct, my test.php is at public_html/ssi/test.php .. However, I am calling from a ZF template file , which gets parsed by ZF always..not sure what you ment by "as long as it's not parsed by ZF" . In my test.php I simple output var_dump($_GET) - nothing else is in that php file, just that one line. And the way I call it from the ZF template file is like so: <!--#include virtual='/ssi/test.php?x=hello' -->

. the strange thing is, that if I type http://mydomain.com/controller/action/?x=hi_there , it will actually pass that X param to my SSI include line , and will overwrite whatever I had there originally (x=hello) . If I don't pass anything in the URL, nothing will get passed to SSI.

like image 718
Gotys Avatar asked Aug 16 '10 12:08

Gotys


2 Answers

Instead of using the SSI include, you could try using the php virtual function:

virtual ("/ssi/test.php?x=hello");

via http://www.zytrax.com/tech/php/php_ssi.htm

What kind of caching requires you to use SSI? Couldn't you just use something like Zend_Cache_Frontend_Output?

like image 87
pharalia Avatar answered Oct 27 '22 02:10

pharalia


I've never seen SSI used with PHP in this way so this is something of a long shot, but can you try changing:

AddOutputFilter INCLUDES .php

to:

AddOutputFilterByType INCLUDES text/html

the reason it's not working is that your files no longer have a .php extension (or any extension), since you're routing everything through index.php. The change I've suggested will filter all text/html output (which should include PHP) though the SSI parser, instead of doing so by extension.

like image 33
Tim Fountain Avatar answered Oct 27 '22 03:10

Tim Fountain