For some reasons i find my self facing this request : Making a redirect from : /_Layouts/AccessDenied.aspx to a Custom ApplicationPage and the modification MUST be done ONLY on web.config which means that i can't use
UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, customAccessDeniedPage)
or any of the solutions on this site
After some research i tried to add this :
<customErrors mode="On" defaultRedirect="~/_layouts/AccessDenied.aspx">
<error redirect="~/_layouts/MySite/Pages/AccessDenied.aspx" statusCode="401" />
<error redirect="~/_layouts/MySite/Pages/AccessDenied.aspx" statusCode="403" />
</customErrors>
And this :
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Auto">
</httpErrors>
but it didn't make a redirect, even if, under the IIS --> MySite the redirect exist !