在windows主机修改web.config文件中将所有html页面处理为php

问题描述 投票:1回答:1

我在所有350 .html页面中插入了PHP代码。我不可能将所有扩展名更改为.php我需要处理所有.html页面,如.php

我找到了在.htaccess文件中执行此操作的说明,但我的主机是Windows。我只能修改web.config文件,我无权访问IIS管理器或其他资源。

我找到的.htaccess代码是:

AddType application/x-httpd-php5 .html .htm

但我需要它为web.config文件。

谢谢。

php html .htaccess web-config windows-hosting
1个回答
0
投票

首先备份你的文件

在文件夹中创建一个新的php文件,包含要更改的文件,将此代码添加到文件中

<?php
    foreach (glob("*.html") as $filename) {
        list($name, $ext) = explode('.', $filename);
        rename($filename, $name.'.php');
    }
?>
© www.soinside.com 2019 - 2024. All rights reserved.