我有一个使用了10年的Apache服务器(FreeBSD),它可以运行以下内容:
File1.htm
<!-- #set var="myDir" value="/dir" -->File2.htm
<!-- #include virtual="File1.htm" --> //sets myDir
<!-- #include virtual="${myDir}/File3.htm" --> //loads /dir/File3.htmFile3.htm
<!-- #include virtual="${myDir}/File4.htm --> //loads /dir/File4.htm在最新的带有最新Apache的Suse Linux上,似乎没有在File3.htm中定义myDir,因此它无法找到并加载File4。
因此File2可以加载File3,但File3无法加载File4。它可以在10年前的FreeBSD上运行,但不能在最近运行在Linux上的Apache上运行。
有什么想法吗?
为了完整起见进行编辑,这基本上是配置文件:
DocumentRoot "/srv/www/htdocs"
<Directory "/srv/www/htdocs">
Options Includes
AddType text/html .htm
AddOutputFilter INCLUDES .htm
AllowOverride None
Order allow,deny
Allow from all
</Directory>发布于 2012-08-31 04:16:38
我已经在我的Ubuntu11.04系统(使用Apache2.2.17)上进行了测试,没有任何问题。
以下是我使用过的文件:
File1.htm (位于File2.htm的同一文件夹中)
<ul>
<li>
<p>Start File1</p>
<!--#set var="myDir" value="/test/stackoverflow/ssi" -->
<!--#echo var="myDir" -->
<p>End File1</p>
</li>
</ul>File2.htm (位于File1.htm的同一文件夹中)
<!DOCTYPE html>
<html>
<head>
<title>Apache SSI test</title>
</head>
<body>
<ul>
<li>
<p>Start File2</p>
<!--#include virtual="File1.htm" -->
<p><!--#echo var="myDir" --></p>
<!--#include virtual="${myDir}/File3.htm" -->
<p>End File2</p>
</li>
</ul>
</body>
</html>File3.htm (位于"ssi“子文件夹中)
<ul>
<li>
<p>Start File3</p>
<p><!--#echo var="myDir" --></p>
<!--#include virtual="${myDir}/File4.htm" -->
<p>End File3</p>
</li>
</ul>File4.htm (位于"ssi“子文件夹中)
<ul>
<li>
<p>Start File4</p>
<p><!--#echo var="myDir" --></p>
<p><!--#echo var="DATE_LOCAL" --></p>
<p>End File4</p>
</li>
</ul>这是我的".htaccess“文件:
Options +Includes
AddType text/html .htm
AddOutputFilter INCLUDES .htm下面是我在浏览器中请求页面"File2.htm“得到的输出:
- Start File1
/test/stackoverflow/ssi End File1 /test/stackoverflow/ssi - Start File3
/test/stackoverflow/ssi - Start File4
/test/stackoverflow/ssi
Thursday, 30-Aug-2012 21:45:57 CEST
End File4 End File3 End File2 您还应该:
Apache
中的错误。
顺便说一下,我想你的"File3.htm“中缺少的右引号只是一个打字错误。
https://stackoverflow.com/questions/12152226
复制相似问题