允许使用 MAMP 对 htdocs 文件夹中的所有 HTML 页面进行 SSI 包含指令
我使用 MAMP 来开发网站。我将每个站点都放在 htdocs 文件夹中自己的文件夹中。我管理一个需要使用 ssi 指令的网站,因为主机不允许包含 php。
我已在 httpd.conf 文件中取消注释这些行:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
我在 htdocs 文件夹中添加了一个 .htaccess 文件,其中包含以下内容:
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
在站点索引页面上,包含有效using:
<!--#include file="top-nav.shtml" -->
但它不适用于任何子文件夹中的文件。我收到此错误:
[an error occurred while processing this directive]
I use MAMP to develop sites. I have each site in it's own folder in the htdocs folder. I manage one site that I need to use ssi directives on, because the host doesn't allow php includes.
I've un-commented these lines in httpd.conf file:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
I added a .htaccess file in the htdocs folder with the following:
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
On the site index page the include works using:
<!--#include file="top-nav.shtml" -->
But it does not work on files in any sub folder. I get this error:
[an error occurred while processing this directive]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现按照这些设置过程 SSI 仍然失败的最常见原因是在浏览器中调用本地网页时未指定端口(
默认 8888
)。请参阅:http://documentation.mamp.info/en/mamp/first-steps
I find the most common reason that SSI still fails following these set up procedures is that that the port (
default 8888
) is not specified when calling the local web page in the browser.See: http://documentation.mamp.info/en/mamp/first-steps
事实证明,使用
virtual
而不是file
适用于子目录。我仍然不确定是否有任何特殊原因file
不起作用。该问题已在 serverfault.com 上得到解答。该线程可在此处找到:https://serverfault.com/questions/ 214096/如何为所有 html 文件启用 ssi
It turns out that that using
virtual
rather thanfile
works on sub directories. I'm still not sure if there is any particular reasonfile
doesn't work. The question was answered on serverfault.com.The thread is available here: https://serverfault.com/questions/214096/how-to-enable-ssi-for-all-html-files