0

我已经研究了大约 2 个多小时,其中包括 1 个多小时的准备报告(考虑到我 24 小时没有睡觉,我一定是个慢工:-P)

虚拟服务器端包括在 Dreamweaver 中的工作(图像渲染除外),但在我浏览网页时不起作用。

<!--#include virtual="/partialHtml/businessResult.shtml" -->

我意识到我已经覆盖了太多的配置设置(如果有更简单和更优雅的方式,也许只是使用一个.htaccess文件~/Sites/mysite.com/然后请评论);-)

从顶部开始 (1)sudo nano /etc/apache2/httpd.conf

#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

(2)sudo nano /etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
  <Directory /Users/tidy/Sites/mysite.com>
    Options +FollowSymlinks +SymLinksIfOwnerMatch +Includes
    DirectoryIndex index.htm
    AllowOverride All
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
  </Directory>
  DocumentRoot /Users/tidy/Sites/mysite.com
  ServerName mysite.local
  ErrorLog "/Users/tidy/Sites/mysite.com/log/error_log"
  CustomLog "/Users/tidy/Sites/mysite.com/log/access_log" common
</VirtualHost>

(3)sudo nano /private/etc/apache2/users/tidy.conf

<Directory "/Users/tidy/Sites/">
  Options +Indexes +MultiViews +FollowSymlinks +SymLinksIfOwnerMatch +Includes
  AllowOverride All
  Order allow,deny
  Allow from all
  AddType text/html .shtml
  AddOutputFilter INCLUDES .shtml
</Directory>

(4)sudo nano ~/Sites/mysite.com/.htaccess

AddType text/html .shtml
AddHandler server-parsed .shtml
DirectoryIndex index.html index.htm
Options +Includes
XBitHack on

我还尝试XBitHack on通过执行chmod +x ~/Sites/mysite.com/partialHtml/businessResult.html然后包含该文件来使用(.html如果您不想使用.shtml文件,显然它使文件服务器端包含高效)

显然,我正在做一个sudo apachectl configtest以确保一切正常。

我收到一个警告(我试图摆脱),但语法没问题。

httpd: Could not reliably determine the server's fully qualified domain name, using complexity.local for ServerName
Syntax OK

然后一个sudo apachectl restart

这是我最近的活动cat ~/Sites/mysite.com/log/access_log

::1 - - [08/Jan/2013:12:11:05 +0000] "OPTIONS * HTTP/1.0" 200 -
::1 - - [08/Jan/2013:12:11:07 +0000] "OPTIONS * HTTP/1.0" 200 -
::1 - - [08/Jan/2013:12:11:08 +0000] "OPTIONS * HTTP/1.0" 200 -
::1 - - [08/Jan/2013:12:11:15 +0000] "OPTIONS * HTTP/1.0" 200 -
::1 - - [08/Jan/2013:12:11:16 +0000] "OPTIONS * HTTP/1.0" 200 -
::1 - - [08/Jan/2013:12:11:17 +0000] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET / HTTP/1.1" 200 3924
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET /css/site.css HTTP/1.1" 200 3077
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET /css/bootstrap.css HTTP/1.1" 200 124223
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET /img/logo.png HTTP/1.1" 200 19217
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /img/searchFormGradient.gif HTTP/1.1" 200 501
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /img/glyphicons-halflings-white.png HTTP/1.1" 200 8777
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /img/headerGradient.png HTTP/1.1" 200 216
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /js/bootstrap.min.js HTTP/1.1" 200 31596
::1 - - [08/Jan/2013:12:12:14 +0000] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET / HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /css/bootstrap.css HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /js/bootstrap.min.js HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/logo.png HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /css/site.css HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/headerGradient.png HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/glyphicons-halflings-white.png HTTP/1.1" 304 -
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/searchFormGradient.gif HTTP/1.1" 304 -

HTTP/1.1 304代码HTTP Error 304 - Not modified不是错误,它是从服务器到浏览器的信号,表明当前内容自上次请求以来没有更改。

GET请求中可以看出,没有迹象表明/partialHtml/businessResult.shtml

这是我最近的活动cat ~/Sites/mysite.com/log/error_log

[Tue Jan 08 11:24:49 2013] [error] [client 127.0.0.1] File does not exist: /Users/tidy/Sites/mysite.com/favicon.ico

毕竟......服务器端包含机制不起作用:-(

非常感谢任何帮助。

整齐的。

4

1 回答 1

0

我想我有解决问题的办法。

我在 Windows 7 上使用服务器端包含时遇到了同样的问题,因为我有一种错误的印象,即只有包含的文件必须具有.shtml扩展名。

因为这条线: <!--#include file="partialHtml/businessResult.shtml" -->

在一个名为: index.html

服务器端包含模块未预处理文件。

在我更改index.htmlindex.shtml服务器端包含模块后,正确地预处理了所有内容。

TL;DR - 包含服务器端包含的文件必须具有 .shtml 扩展名。

于 2013-01-12T00:30:29.110 回答