修改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. vue组件推荐

    Vue 是一个轻巧.高性能.可组件化的MVVM库,API简洁明了,上手快.从Vue推出以来,得到众多Web开发者的认可.在公司的Web前端项目开发中,多个项目采用基于Vue的UI组件框架开发,并投入正 ...

  2. Eclipse 配置 Tomcat 服务器

    配置Tomcat 在首先外部安装好Tomcat,然后在eclipse配置Tomcat服务器: 选择要配置的Tomcat版本: 注意:这一步如果勾选了Create a new local server ...

  3. ubuntu 16.04 python版本切换(python2和python3)

    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 sudo update-alternati ...

  4. Linux的用户管理(基础篇)

    用户相关 临时切换用户: su 用户名 完全切换用户: su – 用户名 查看当前登入的用户名: whoami 查看当前用户下的一切环境变量: env 登出当前登入的用户: logout 查看系统的用 ...

  5. 厉害了,Spring Cloud for Alibaba 来了!

    最近,Spring Cloud 发布了 Spring Cloud Alibaba 首个预览版本:Spring Cloud for Alibaba 0.2.0. 大家都好奇,这和阿里巴巴有什么关系?莫非 ...

  6. Spring实战拆书--SpringBean

    代码源码地址:https://github.com/wujiachengSH/springBeanDemo 概述:本章将讲解Spring对于Bean的管理方案. 目录: 准备工作 自动装配 处理装配歧 ...

  7. Mac eos 环境搭建

    最近EOS官网出了文档,说可以跑通一个独立测试的节点了.这周尝试自行搭建了一下,由于自己不完全做mac下的开发,且这玩意是C写的,所以make起来遇到不少坑,记录下来.附完整踩坑.填坑记录. 1. 搭 ...

  8. 【ABP框架系列学习】介绍篇(1)

      0.引言 该系列博文主要在[官方文档]及[tkbSimplest]ABP框架理论研究系列博文的基础上进行总结的,或许大家会质问,别人都已经翻译过了,这不是多此一举吗?原因如下: 1.[tkbSim ...

  9. Android数据保存之SharedPreference

    前言: 程序中处理的大部分问题都与数据有关,读取数据显示在UI上,读取的数据可以是本地的,也可以是网络的.保存用户数据到存储空间,可以是本地的数据库,文件等,也可以是保存到网络服务器.总之大部分的程序 ...

  10. vue-15-vuex-store的用法

    vue-16-vuex 1, 介绍 对 vue 进行状态管理的, 集中存储所有组件的所有状态, 解决多个组件共享数据的问题. 即, 所有组件可以拿到同样的状态, 组件间共享数据 2, 在之前进行数据交 ...