IP restriction error message

℡╲_俬逩灬. 提交于 2019-12-11 10:48:43

问题


Say, If I restrict access to a site's subfolder using "IP address and domain restrictions", what would be the IIS error message I would be getting? I need to use a custom error message like "Your IP is not allowed to access this site", but would that be possible? I am asking if the same same error code (like a generic access denied that is returned for Certificate error) is returned for this, then I won't be able to use it.

Is it possible to get a unique error when a request fail at the "IP address and domain restrictions" rule?


回答1:


IIS will raise a HTTP 403.6 - Forbidden: IP address rejected.

If you want to display a custom error page then go to your website within the IIS Manager and look for "Error Pages" under the IIS section, on the right hand side under "Actions" click "Add...", fill out the window using status code 403.6 and choose your action.

This can also be achieved by modifying your websites web.config file, just add an <error> entry to the <httpErrors> section as shown below:

<system.webServer>
    <httpErrors>
        <error statusCode="403" subStatusCode="6" path="/errors/iprestricted.html" responseMode="ExecuteURL" />
    </httpErrors>
</system.webServer>


来源:https://stackoverflow.com/questions/19771041/ip-restriction-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!