日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

apache配置-html碎片shtml格式

發布時間:2023/12/2 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 ?//這個是添加默認的索引文件

</IfModule>

<Directory "D:/htdocs/test"> ?//修改文件目錄

? ? AllowOverride None

? ? Options None

? ? Order allow,deny

? ? Allow from all

</Directory>

詳解:

如何使你的Apache服務器支持SSI?

Apache(如何在windows以及linuc下安裝apache請參見另兩篇文章)默認是不支持SSI的,需要我們更改httpd.conf來進行配置。我這里以windows平臺的Apache 2.0.x為例(在linux平臺下與之相同),打開conf目錄下的httpd.conf文件,搜索“AddType text/html .shtml”,找到:

以下是引用片段:
# AddType text/html .shtml?
# AddOutputFilter INCLUDES .shtml

把這兩行前面的#去掉 。

然后搜索“Options Indexes FollowSymLinks”

在搜索到的那一行后面添加“ Includes”

即將該行改變為 Options Indexes FollowSymLinks Includes

熟悉apache manual的可能會覺得比較容易。

保存httpd.conf,重起apache即可

到此我們就完成了對Apache SSI的設置。

cmd命令檢查配置文件:

httpd.exe -t

?

總結如下:

方法1–apache配置:


1. 確認加載include.so模塊,將注釋去掉:?
LoadModule include_module libexec/apache2/mod_include.so?


2. AddType部分去掉這兩段注釋:?
AddType text/html .shtml?
AddOutputFilter INCLUDES .shtml?


3. Directory目錄權限里面找到?
Options Indexes FollowSymLinks?
增加Includes修改為:?
Options Indexes FollowSymLinks Includes?


4. 重新啟動Apache,測試:?
<!–#include file=”head.html”–>?
Holle Word!,這是中間的內容?
<!–#include file=”foot.html”–>

?

方法2–.創建文件.htaccess

如果用戶不能直接訪問服務器配置文件,可以使用文件編輯器創建一個名為.htaccess的文件。注意,文件名前一定要有符號“.”,這樣服務器才能知道該文件是隱藏文件,從而提高文件的安全性,避免錯誤操作。在.htaccess文件中需要加入以下三行文字:
Options Indexes FollowSymLinks Includes?
AddType application/x-httpd-CGI .CGI?
AddType text/x-server-parsed-html .shtml
完成之后可以把.htaccess文件上傳到服務端的相應目錄,該文件對所有子目錄有效。如果用戶希望在目錄級上禁止CGI或shell命令,可以在.htaccess文件中的Options選項行加入關鍵字IncludesNOEXEC

?

在頁面中引入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 到下面即可


更多專業前端知識,請上 【猿2048】www.mk2048.com

總結

以上是生活随笔為你收集整理的apache配置-html碎片shtml格式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。