php - 过滤传出的 html 文件

标签 php html .htaccess

我在所有 *.html 文件中都有自定义语法,需要在提供之前通过 filter.php 进行过滤。我假设这可以通过 .htaccess 完成。

请注意,我不想将 *.html 解析为 PHP。

example

最佳答案

在你的htaccess中,添加

RewriteRule (.*\.html) filter.php?htmlfile=$1

现在,在 filter.php 中,您可以

$html = file_get_contents($_GET['htmlfile']);
// and do whatever you need to do
// then
echo $html;

关于php - 过滤传出的 html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15538944/

相关文章:

php - 从 53 个表返回 mysql 数据库的 p_id 和 t_id 记录?

javascript - 基于标记的中心传单 map

.htaccess - 使用 Apache2 在 Ubuntu 12.04 上启用 htaccess 错误

apache - .htaccess 将 imgname.jpg 改写为 image.php?img=imgname

PHP 比较一个数组的值和另一个数组的键

php - PHP 上的矢量变量值

php - 使用相同名字和姓氏注册并登录多个用户

Javascript 未在网站中加载

performance - .htaccess mod_rewrite 性能

php - 解析错误: syntax error, unexpected '=>' (T_DOUBLE_ARROW) at line 3 [closed]