【问题标题】:Hardening uploads folder in IIS breaks images强化 IIS 中的上传文件夹会破坏图像
【发布时间】:2018-05-31 21:02:24
【问题描述】:

我的网站使用直接 URL 从上传文件夹加载了一堆图片,例如:

http://www.example.com/wp-content/uploads/some.image.png

我正在尝试解决远程脚本执行问题,https://codex.wordpress.org/Hardening_WordPress 上推荐的一件事是使用 .htaccess 文件防止在上传文件夹中执行脚本:

# Kill PHP Execution
<Files ~ "\.ph(?:p[345]?|t|tml)$">
   deny from all
</Files>

我的网站在 IIS 上运行,因此为了获得相同的结果,我删除了上传文件夹及其所有子文件夹的 PHP 处理程序:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
        <handlers>
           <remove  name="php-7.1.7" />
        </handlers>
    </system.webServer>
</configuration>

但是,如果我使用 web.config 文件,使用直接 URL 加载图像会导致 http 500 错误。因此,主题无法正确加载。

如何在不中断静态文件加载的情况下阻止 PHP 脚本在上传文件夹中执行?

&lt;remove name="php-7.1.7" /&gt; 下方添加&lt;add name="StaticFile" /&gt; 没有区别。

【问题讨论】:

标签: wordpress .htaccess iis web-config


【解决方案1】:

在上传文件夹中创建一个 web.config 并粘贴以下 xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers accessPolicy="Read"> 
         </handlers>
    </system.webServer>
</configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-23
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多