apache - SSI 转义 HTML 输出

标签 apache escaping echo ssi directive

当我使用 SSI 指令时,有没有办法用 HTML 实体转义变量?

<META HTTP-EQUIV="Refresh" CONTENT="10; URL="/index.shtml?r=<!--#echo var="HTTP_REFERER" -->">

谢谢你的建议!

最佳答案

参见 http://httpd.apache.org/docs/2.2/mod/mod_include.html 的 mod_include 文档中 'The echo Element' 下的 'encoding' :

Specifies how Apache should encode special characters contained in the variable before outputting them. If set to none, no encoding will be done. If set to url, then URL encoding (also known as %-encoding; this is appropriate for use within URLs in links, etc.) will be performed. At the start of an echo element, the default is set to entity, resulting in entity encoding (which is appropriate in the context of a block-level HTML element, e.g. a paragraph of text). This can be changed by adding an encoding attribute, which will remain in effect until the next encoding attribute is encountered or the element ends, whichever comes first.

The encoding attribute must precede the corresponding var attribute to be effective, and only special characters as defined in the ISO-8859-1 character encoding will be encoded. This encoding process may not have the desired result if a different character encoding is in use.

关于apache - SSI 转义 HTML 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1282442/

相关文章:

java - 在 Mac OSX 上设置 lucene 时遇到问题

c - 如何将-o生成的C程序输出添加到$PATH?

php - 回应 Fetch_Assoc 失败

bash - 如何避免 echo 关闭 FIFO 命名管道? - Unix FIFO 的有趣行为

multithreading - 如何在 Node.js 应用程序中使用 Apache OpenNLP

apache - Apache 上的 CoAP,CoAP Web 服务

apache - 无法在 CentOS 上放大 Munin 图

c# - 字符串转义为 XML

go - 如何阻止html模板转义

C#:使用 XmlTextWriter 清理 XML 文本值?