我在我的iis7.5服務器上有一個文件(名爲'log.html'),我希望我的PHP安裝能夠訪問和寫入,但我確實不想讓任何人直接訪問文件,例如輸入'http://computername/log.html'(我在LAN上)。只允許腳本訪問文件iis7.5
如何防止用戶訪問它,但允許php看到它?
當使用web.config文件以下建議,我得到這個錯誤:
我在我的iis7.5服務器上有一個文件(名爲'log.html'),我希望我的PHP安裝能夠訪問和寫入,但我確實不想讓任何人直接訪問文件,例如輸入'http://computername/log.html'(我在LAN上)。只允許腳本訪問文件iis7.5
如何防止用戶訪問它,但允許php看到它?
當使用web.config文件以下建議,我得到這個錯誤:
我想我可能已經回答了我自己的問題!我還需要測試它多一點,也許,如果它不完全工作,然後有人可以糾正我:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="cache-control" value="no-store, no-cache, must-revalidate, max-age=0" />
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="log.html" />
</denyUrlSequences>
</requestFiltering>
</security>
</system.webServer>
</configuration>
高速緩存控制位防止瀏覽器緩存任何東西,它回來了。
希望這可以幫助別人!我對此仍然很陌生,所以你可能能夠解決這個問題。
您可以使用IIS URL重寫,並創建一個請求阻擋規則防止over HTTP訪問:
對於例如:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="BlockLogFile"
patternSyntax="Wildcard"
stopProcessing="true">
<match url="*" />
<conditions>
<add input="{URL}" pattern="/log.html" />
</conditions>
<action type="CustomResponse"
statusCode="403"
statusReason="Forbidden: Access is denied."
statusDescription="This is sekret!" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
由於某種原因,當我使用你的web.config例子我得到一個內部服務器錯誤(500.19)告訴我,有一個問題,閱讀web.config文件... – starbeamrainbowlabs
@starbeamrainbowlabs - 抱歉,從未注意到您的答覆。配置示例直接從我測試的服務器上覆制。你可以發佈500.19頁面的屏幕截圖,它通常非常豐富。 – Kev
是的,我可以,但我怎麼能顯示它在stackoverflow? – starbeamrainbowlabs
我應該問服務器故障嗎? – starbeamrainbowlabs