我研究了大约2个多小时,包括准备这份报告的1个多小时(我一定是一个很慢的人,考虑到我24小时没有睡觉了:-P)
虚拟服务器端包含Dreamweaver中的工作(除了图像渲染),但当我浏览到网页时不起作用。
<!--#include virtual="/partialHtml/businessResult.shtml" -->
我意识到我已经覆盖了太多的配置设置(如果有一个更简单和更优雅的方式,也许只是在~/Sites/mysite.com/
中使用.htaccess
文件,那么也请评论);-)
从顶部开始(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
Then a 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
在那之后…服务器端Include机制不工作:-(
)任何帮助都是非常感谢的。
整洁。
我想我有解决问题的办法了。
我在Windows 7上的服务器端包含有同样的问题,因为我错误地认为只有包含的文件必须有.shtml
扩展名。
因为这一行:<!--#include file="partialHtml/businessResult.shtml" -->
在一个名为:index.html
服务器端include模块未对文件进行预处理。
在我将index.html
更改为index.shtml
后,服务器端包含模块正确预处理一切。
TL;DR -包含服务器端include的文件必须具有。shtml扩展名