修改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 到下面即可

apache配置-html碎片shtml格式的更多相关文章

  1. 【server端学习】修改Apache配置使支持shtml

    主要工作:修改httpd.conf文件[步骤一]去掉下面两行的注释#AddType text/html .shtml #AddOutputFilter INCLUDES .shtml [步骤二]在Op ...

  2. 在Apache下开启SSI配置支持include shtml html和快速配置服务器

    作为前端开发,使用Apache快速搭建服务器极为方便. 1.找到apach安装目录,找到conf目录下 的httpd.conf 使用SSI(Server Side Include)的html文件扩展名 ...

  3. Apache配置虚拟目录,以及各种操作

    apache配置虚拟目录: 打开并创建虚拟目录的步骤如下: # Virtual hosts # Include conf/extra/httpd-vhosts.conf 去掉conf/http.con ...

  4. lamp apache配置虚拟主机

    You don't have permission to access /index.php on this server

  5. Apache配置支持include

    Apache配置支持include 什么是SSI? SSI是英文Server Side Includes的缩写,翻译成中文就是服务器端包含的意思.从技术角度上说,SSI就是HTML文件中,可以通过注释 ...

  6. Windows上为Apache配置HTTPS

    Windows上为Apache配置HTTPS   转 https://www.cnblogs.com/tianzijiaozi/p/7582671.html   1. 安装OpenSSL: Windo ...

  7. 服务器 apache配置https,http强制跳转https(搭建http与https共存)

    公司linux服务器上的nginx的已经改成https了,现在还剩下一个windows云服务器没配置. 环境 windows wampserver2.5 64位 1.腾讯云申请的ssl 包含三个文件: ...

  8. centos LAMP第二部分apache配置 下载discuz!配置第一个虚拟主机 安装Discuz! 用户认证 配置域名跳转 配置apache的访问日志 配置静态文件缓存 配置防盗链 访问控制 apache rewrite 配置开机启动apache tcpdump 第二十节课

    centos    LAMP第二部分apache配置  下载discuz!配置第一个虚拟主机 安装Discuz! 用户认证 配置域名跳转  配置apache的访问日志  配置静态文件缓存  配置防盗链 ...

  9. Apache——配置与应用

    Apache配置与应用 1.概述 2.httpd服务支持的虚拟主机类型 3.构建虚拟Web主机 4.构建Web虚拟目录与用户授权限制 5.日志分割 6.AWStats分析系统 1.概述: 虚拟web主 ...

随机推荐

  1. MySQL结构

    MySQL属于关系型数据库管理系统(RDBMS),使用RDBMS时,最常见的系统结构就是客户端/服务器类型(C/S类型)这种结构. 服务器指的是用来接收其他程序发出的请求,并对该请求进行相应处理的程序 ...

  2. swiper里面几个有用的参数

    概述 这是我自己用swiper和看别人官网源码用swiper总结出来的,供以后开发时参考,相信对其他人也有用. observeParents 有时我们会改变swiper的父级元素,比如页面的resiz ...

  3. Linux rpm包安装不了

    有时候会发现安装rpm包时会报错,解决办法: 到rpm包所在目录执行 createrepo -v ./   这个命令 然后会生成一个repodate这个目录,然后在进行安装rpm就可以了!

  4. ubuntu 16.04 下安装动态链接库方法

    一般先使用ldd 来查看该应用程序缺少什么东西,然后,再根据sudo apt install XXX 去安装相应的动态库. 假如没有对应的库,可以使用: sudo ln -s /usr/lib/lib ...

  5. python(leetcode)-283移动零

    给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序. 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须在原数组上操作, ...

  6. 【新手向】使用nodejs抓取百度贴吧内容

    参考教程:https://github.com/alsotang/node-lessons 1~5节 1. 通过superagent抓取页面内容 superagent .get('http://www ...

  7. Merge branch 'master' of xxx error

    Merge branch 'master' of xxx Please enter a commit message to explain why this merge is necessary,es ...

  8. odoo开发笔记 -- tree视图按指定字段group_by分组显示

    注意点: view视图文件中的搜索视图要放在action视图的前边. 在action视图中,要写search_view_id, 还有context, search_default_group_by_字 ...

  9. Day2----Python学习之路笔记(2)

    学习路线: Day1 Day2 Day3 Day4 Day5 ...待续 一.简单回顾一下昨天的内容 1. 昨天了解到了一些编码的知识 1.1. 我们写好的.py文件头没有加# -*- coding: ...

  10. Java多线程之二(Synchronized)

    常用API method 注释 run() run()方法是我们创建线程时必须要实现的方法,但是实际上该方法只是一个普通方法,直接调用并没有开启线程的作用. start() start()方法作用为使 ...