我現在有一個登錄系統來阻止所有未經過身份驗證的用戶查看我網站的內容。我可以確認登錄作品。 但是我現在面臨的問題是使用我的web.config文件。我可以阻止未經驗證的用戶查看主頁面(即www.mysite.com),從而加載index.php。用戶雖然仍然可以訪問www.mysite.com/index.php而不登錄登錄目的。Web.Config來封鎖整個網站
我的web.config只處理主頁面和我在根目錄下的任何.aspx文件。 以下是我的web.config代碼。我已經找了一段時間的解決方案,並沒有找到一種方法,使web.config工作的整個網站。此外,它位於根(和我的網站使用wordpress)。因爲我已經花了相當長一段時間對這個
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="false" />
<customErrors mode="Off" />
<authentication mode="Forms">
<forms
name=".myCookie"
loginUrl="http://www.mysite.com"
domain="mysite.com"
protection="All"
timeout="120"
path="/"
requireSSL="false"
slidingExpiration="true"
/>
</authentication>
<authorization>
<allow roles="AA,BB" />
<deny users="*" />
</authorization>
<machineKey
validationKey="xxxxxxx"
decryptionKey="xxxxxxx"
validation="SHA1"
/>
<sessionState mode="Off" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
任何幫助,將不勝感激,我覺得這應該是一個簡單的解決方案。我也在運行IIS 7.
總結我的問題,我需要web.config文件來阻止對所有類型的文件(php,.txt等)的訪問,而不僅僅是根URL和.aspx文件。
謝謝
作爲更新的事。看來我被system.web vs system.webserver這兩行弄糊塗了。由於我在運行IIS7,因此我應該將驗證放入配置的web服務器部分。 – Jingles177