修改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. 吴恩达机器学习笔记13-正规方程(Normal Equation)

    到目前为止,我们都在使用梯度下降算法,但是对于某些线性回归问题,正规方程方法是更好的解决方案.如: 即: 运用正规方程方法求解参数: 注:对于那些不可逆的矩阵(通常是因为特征之间不独立,如同时包含英尺 ...

  2. Python中list的删除del&remove小区别

    del删除时候指定下标,remove必须指定具体的值

  3. MySQL-5.7.19 在阿里云 CentOS-7.0 上的安装

    工具准备 查看系统是否安装了yum工具: [root@wangbo srv]# rpm -qa | grep yum yum-metadata-parser-1.1.4-10.el7.x86_64 y ...

  4. 如何解决git====push 过程中出现的。error: failed to push some refs

    当我们在利用git  push 文件到仓库时出现了一下问题: ! [rejected] master -> master (fetch first)error: failed to push s ...

  5. 【PHP篇】面向对象基础

    1.声明:class 类名{ //成员属性(变量) 修饰符 $变量名=初值: //成员方法(函数) 修饰符 function 函数名(){ 执行:} } 2.生成类对象:$对象名=new 类名():/ ...

  6. 多线程 Thread.yield 方法到底有什么用?

    概念 我们知道 start() 方法是启动线程,让线程变成就绪状态等待 CPU 调度后执行. 那 yield() 方法是干什么用的呢?来看下源码. /** * A hint to the schedu ...

  7. linux设置打开文件句柄数

    介绍 在Linux下有时会遇到Socket/File : Can't open so many files的问题.其实Linux是有文件句柄限制的,而且Linux默认一般都是1024(阿里云主机默认是 ...

  8. Android布局中的空格以及占一个汉字宽度的空格,实现不同汉字字数对齐

    前言 在Android布局中进行使用到空格,以便实现文字的对齐.那么在Android中如何表示一个空格呢? 空格: (普通的英文半角空格但不换行) 窄空格:   (中文全角空格 (一个中文宽度))   ...

  9. pyinstaller安装配置

    一.工具准备: 1).安装pyinstaller需要以这个包为基础.也就是基础软件包.pyWin32包.下载对应的pyWin32安装包>>地址: https://sourceforge.n ...

  10. flex布局常见用法小结

    1,display:flex 这个在父容器中声明: 2,flex-direction:row / column 默认为横向,也在父容器中设置,定义flex布局的主轴方向:一条轴为主轴,那么另一条轴自然 ...