简体   繁体   English

为什么我的SSI不起作用?

[英]Why doesn't my SSI work?

I am having problems with passing query params into SSI include from within my zend framework application. 我遇到了将查询参数传递到我的zend框架应用程序中的SSI包含的问题。

I am trying to include a PHP file inside another PHP: 我想在另一个PHP中包含一个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. 如果我的hellotest.php(包含上面的行)驻留在我的文档根目录中,这将正确执行。

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). 但是,如果我从template.phtml(不再是/public_html/hellotest.php)中做同样的事情(我在这个项目中使用Zend Framework),则调用test.php并执行它而不使用任何查询参数(在此case x =你好)。 No query parameters are passed into test.php from withitn my zend_framework templates . 没有查询参数从withitn my zend_framework模板传递到test.php。

Does this have anything to do with the way zend framework uses .htaccess ? 这与zend框架使用.htaccess的方式有什么关系吗? Here is a copy of my .htaccess files (in web root: /public_html/.htaccess) 这是我的.htaccess文件的副本(在web根目录中:/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 . 编辑:我最近发现,它会将参数传递到从URL中获取的SSI。 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. 因此,如果在我的浏览器中输入http://www.test.com/controller/action?param1=something ,它实际上会将param1传递给SSI,但它将完全忽略我在SSI行上的参数。 ... 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" . EDIT2 - 响应Tim Fountain:对,我的test.php是在public_html / ssi / test.php ..但是,我是从一个ZF模板文件中调用的,它总是由ZF解析。不知道你的意思是什么“只要它不被ZF解析”。 In my test.php I simple output var_dump($_GET) - nothing else is in that php file, just that one line. 在我的test.php中我简单输出var_dump($ _ GET) - 那个php文件中没有别的东西,就是那一行。 And the way I call it from the ZF template file is like so: <!--#include virtual='/ssi/test.php?x=hello' --> 我从ZF模板文件中调用它的方式如下: <!--#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) . 奇怪的是,如果我键入http://mydomain.com/controller/action/?x=hi_there ,它实际上会将X参数传递给我的SSI包含行,并且会覆盖我原来的那些(x =你好) 。 If I don't pass anything in the URL, nothing will get passed to SSI. 如果我没有在URL中传递任何内容,则不会将任何内容传递给SSI。

Instead of using the SSI include, you could try using the php virtual function: 您可以尝试使用php虚函数,而不是使用SSI include:

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

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

What kind of caching requires you to use SSI? 什么样的缓存需要您使用SSI? Couldn't you just use something like Zend_Cache_Frontend_Output? 难道你不能只使用像Zend_Cache_Frontend_Output这样的东西吗?

I've never seen SSI used with PHP in this way so this is something of a long shot, but can you try changing: 我从来没有见过用这种方式与PHP一起使用的SSI所以这是一个很长的镜头,但是你可以尝试改变:

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. 它不起作用的原因是你的文件不再具有.php扩展名(或任何扩展名),因为你通过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. 我建议的更改将通过SSI解析器过滤所有text / html输出(应该包括PHP),而不是通过扩展来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM