apache配置-html碎片shtml格式
修改SSI 文件
conf–httpd.conf
<Directory "D:/Android/Apache2.2/htdocs"> ?//修改文件目錄
? ? #
? ? # Possible values for the Options directive are "None", "All",
? ? # or any combination of:
? ? # ? Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
? ? #
? ? # Note that "MultiViews" must be named *explicitly* — "Options All"
? ? # doesn't give it to you.
? ? #
? ? # The Options directive is both complicated and important. ?Please see
? ? # http://httpd.apache.org/docs/2.2/mod/core.html#options
? ? # for more information.
? ? #
? ? Options Indexes FollowSymLinks?Includes //添加include
? ? #
? ? # AllowOverride controls what directives may be placed in .htaccess files.
? ? # It can be "All", "None", or any combination of the keywords:
? ? # ? Options FileInfo AuthConfig Limit
? ? #
? ? AllowOverride None
? ??AddType text/html .shtml ?
? ? AddOutputFilter INCLUDES .shtml?//添加include
? ? #
? ? # Controls who can get stuff from this server.
? ? #
? ? Order allow,deny
? ? Allow from all
</Directory>
<IfModule dir_module>
? ?DirectoryIndex index.html index.shtml ?//這個(gè)是添加默認(rèn)的索引文件
</IfModule>
<Directory "D:/htdocs/test"> ?//修改文件目錄
? ? AllowOverride None
? ? Options None
? ? Order allow,deny
? ? Allow from all
</Directory>
詳解:
如何使你的Apache服務(wù)器支持SSI?
Apache(如何在windows以及l(fā)inuc下安裝apache請(qǐng)參見(jiàn)另兩篇文章)默認(rèn)是不支持SSI的,需要我們更改httpd.conf來(lái)進(jìn)行配置。我這里以windows平臺(tái)的Apache 2.0.x為例(在linux平臺(tái)下與之相同),打開(kāi)conf目錄下的httpd.conf文件,搜索“AddType text/html .shtml”,找到:
以下是引用片段:
# AddType text/html .shtml?
# AddOutputFilter INCLUDES .shtml
把這兩行前面的#去掉 。
然后搜索“Options Indexes FollowSymLinks”
在搜索到的那一行后面添加“ Includes”
即將該行改變?yōu)?Options Indexes FollowSymLinks Includes
熟悉apache manual的可能會(huì)覺(jué)得比較容易。
保存httpd.conf,重起apache即可
到此我們就完成了對(duì)Apache SSI的設(shè)置。
cmd命令檢查配置文件:
httpd.exe -t
?
總結(jié)如下:
方法1–apache配置:
1. 確認(rèn)加載include.so模塊,將注釋去掉:?
LoadModule include_module libexec/apache2/mod_include.so?
2. AddType部分去掉這兩段注釋:?
AddType text/html .shtml?
AddOutputFilter INCLUDES .shtml?
3. Directory目錄權(quán)限里面找到?
Options Indexes FollowSymLinks?
增加Includes修改為:?
Options Indexes FollowSymLinks Includes?
4. 重新啟動(dòng)Apache,測(cè)試:?
<!–#include file=”head.html”–>?
Holle Word!,這是中間的內(nèi)容?
<!–#include file=”foot.html”–>
?
方法2–.創(chuàng)建文件.htaccess
如果用戶不能直接訪問(wèn)服務(wù)器配置文件,可以使用文件編輯器創(chuàng)建一個(gè)名為.htaccess的文件。注意,文件名前一定要有符號(hào)“.”,這樣服務(wù)器才能知道該文件是隱藏文件,從而提高文件的安全性,避免錯(cuò)誤操作。在.htaccess文件中需要加入以下三行文字:
Options Indexes FollowSymLinks Includes?
AddType application/x-httpd-CGI .CGI?
AddType text/x-server-parsed-html .shtml
完成之后可以把.htaccess文件上傳到服務(wù)端的相應(yīng)目錄,該文件對(duì)所有子目錄有效。如果用戶希望在目錄級(jí)上禁止CGI或shell命令,可以在.htaccess文件中的Options選項(xiàng)行加入關(guān)鍵字IncludesNOEXEC
?
在頁(yè)面中引入shtml代碼:
<!--#include virtual="inc/head.shtml"-->
<!--#include virtual="inc/footer.shtml"-->
?
如果需要使用html解析包含,??
AddType application/x-httpd-CGI .CGI?
AddType text/x-server-parsed-html .shtml在 它后面添加
添加 AddOutputFilter INCLUDES .html 到下面即可
更多專業(yè)前端知識(shí),請(qǐng)上 【猿2048】www.mk2048.com
總結(jié)
以上是生活随笔為你收集整理的apache配置-html碎片shtml格式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: JS对url进行编码和解码(三种方式区别
- 下一篇: bootstrap源码之滚动监听组件sc