无法让服务器端包含(将一个 HTML 文件放入另一个文件中)工作
我无法让服务器端包含工作。我只是想将一个 html 文件包含到另一个文件中,但我似乎无法让它工作
安装
服务器是另一台运行 Windows XP 的计算机(不是本地主机)。我有一个稍旧版本的 xampp 堆栈,仅运行 Apache/2.2.11
虚拟目录(在 httpd-vhosts.conf 中)配置为
<目录“c:\www\dev1”> 选项索引 FollowSymLinks 包括 ExecCGI 允许覆盖全部 订单允许、拒绝 允许所有
index.html 包含
A Big Block of Text<br />
A Big Block of Text<br />
<!-- #include file="test.shtml" -->
A Big Block of Text<br />
A Big Block of Text<br />
test.shtml 包含
This is another line
我得到的内容
从我的开发机器上的浏览器中,www.dev.com/index.html 显示
A Big Block of Text<br />
A Big Block of Text<br />
A Big Block of Text<br />
A Big Block of Text<br />
- 页面源显示 !--- 包含 这意味着包含文件还没有 已处理
- www.dev.com/test.shtml 显示如上所述的文件,所以 它是可以访问的。
我尝试过的事情
阅读了 stackoverflow 和互联网上的一堆帖子,它帮助“构建”了使其工作的基础知识(即确保选项已启用包含),但它仍然无法工作。
重新启动 apache 后进行更改
Options Indexes FollowSymLinks Includes ExecCGI to
Options Indexes FollowSymLinks Includes +Include ExecCGI to
Options Indexes FollowSymLinks +Includes ExecCGI
,但仍然不起作用
将 .htaccess 添加到与 index.html 和 test.shtml 相同的目录中
Options Indexes FollowSymLinks Includes ExecCGI
AddType text/html .shtml
AddHandler server-parsed .shtml
,但仍然不起作用。
笔记。 http.conf 已经
AddType text/html .shtml
AddHandler server-parsed .shtml
启用。
是的,这可能是非常明显的事情,但我感冒了,所以如果有人能给我指出正确的方向,我将不胜感激。
我尝试过的更多事情
更改包含文件以包含虚拟
我尝试了 RichieHindle 的建议,但它似乎不起作用,我修改了我的 .htaccess 和虚拟目录配置以包含两者所需的 AddType、AddHandler 组合。 html 和 .shtml ...仍然没什么
大注意:在网络服务器上,可以加载 SSI 检查网页(通过 xampp 安装目录之一中的本地主机),它告诉我 SSI 包含已启用并且正在工作,但是,请注意我的虚拟目录不在 xampp 安装目录中;它们在 c:/www 下是独立的...但如果我在虚拟目录设置和/或 .htaccess 设置中配置了上面概述的选项,我无法弄清楚这如何/为什么会产生影响
I can't get server side includes to work. I simply want to include one html file into another and I just can't seem to get it working
Setup
The server is a another machine (not localhost) running Windows XP. I've got a slighly older version of the xampp stack which is running only Apache/2.2.11
Virtual directory (in httpd-vhosts.conf) is configured as
<Directory "c:\www\dev1"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory>
index.html contains
A Big Block of Text<br />
A Big Block of Text<br />
<!-- #include file="test.shtml" -->
A Big Block of Text<br />
A Big Block of Text<br />
test.shtml contains
This is another line
What I am getting
From the browser on my dev machine, www.dev.com/index.html shows
A Big Block of Text<br />
A Big Block of Text<br />
A Big Block of Text<br />
A Big Block of Text<br />
- Page Source shows the !--- include
which means the include file hasn't
been processed - www.dev.com/test.shtml
shows the file as indicated above so
it is accessible.
Things I've tried
Read through a bunch of posts both here on stackoverflow and the internet and its helped "build" the basics for getting this to work (ie make sure Options has Includes enabled) but it still isn't working.
Changed
Options Indexes FollowSymLinks Includes ExecCGI to
Options Indexes FollowSymLinks Includes +Include ExecCGI to
Options Indexes FollowSymLinks +Includes ExecCGI
with an apache restart and it still doesn't work
Added .htaccess to the same directory as index.html and test.shtml
Options Indexes FollowSymLinks Includes ExecCGI
AddType text/html .shtml
AddHandler server-parsed .shtml
and it still doesn't work.
Note. http.conf already has
AddType text/html .shtml
AddHandler server-parsed .shtml
enabled.
Yes, it is probably something real obvious but I've got a cold so if somebody could point me in the right direction, that would be greatly appreciated.
More Things I've Tried
Change include file to include virtual
I tried the suggestion by RichieHindle and it didn't seem to work and I've modified both my .htaccess and virtual directory configuration to include required combinations of AddType, AddHandler for both .html and .shtml ... still nothing
BIG NOTE: On the webserver, one can load a SSI checking webpage (via localhost in one of the xampp install directories) and it tells me that SSI includes are enabled and working, however, please note that my virtual directories are NOT in the xampp install directories; they are standalone under c:/www ... but I can't figure out how/why this makes a difference if I've configured the options outlined above in my virtual directory settings and/or .htaccess settings
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要:
?
您的 HTML 文件名为 index.html,但您仅将
服务器解析
应用于 .shtml 文件。Do you need:
?
Your HTML file is named index.html but you're only applying
server-parsed
to .shtml files.也许尝试删除空格?从:
到此:
Maybe try removing the space? From:
to this:
当谈到将 html 包含在另一个 html 文件中时,我已经搜索并尝试了很多。我不想使用 .asp 或 .php 或 .xhtml。
这对我有用:在 HTML 文件中包含另一个 HTML 文件
I have searched and tried ALOT when it comes to including html in another html file. I did NOT want to use .asp or .php or .xhtml.
this worked for me: Include another HTML file in a HTML file