默认情况下,IIS会隐藏细分web.config
,bin
,App_Code
等等。
但是在我的网站的子文件夹中有相同的文件夹/文件。
我想隐藏默认路径,不想隐藏子文件夹中的文件夹/文件。
e.g。
网站网址:www.abc.com
此后网址应该拒绝:
www.abc.com/web.config
www.abc.com/bin/*
www.abc.com/App_Code/*
此后网址应该允许
www.abc.com/xyz/web.config
www.abc.com/xyz/bin/*
www.abc.com/xyz/App_Code/*
如何配置?
答案 0 :(得分:0)
您可以在“请求过滤”中删除子文件夹的隐藏细分,对于web.config
,您必须从Hidden Segments
和File Name Extensions
中删除它。
答案 1 :(得分:0)
感谢@Kambiz Shahim。
我的解决方案是:
将root web.config设置如下
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true">
<clear />
</fileExtensions>
<hiddenSegments>
<clear />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
将web.config设置为您要隐藏的每个文件夹的下方
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="/" />
</denyUrlSequences>
</requestFiltering>
</security>
</system.webServer>
</configuration>