If you want to redirect to static HTML pages (hosted in a folder at the root of the Web Site in IIS), the following modifications in the web.config (under <configuration>/<system.webServer>) should do the trick for 404 an 500 errors:
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="http://sharepoint2013/Error/404.html" responseMode="Redirect" />
<remove statusCode="500" />
<error statusCode="500" path="http://sharepoint2013/Error/500.html" responseMode="Redirect" />
</httpErrors>
Also: be sure the "Test" folder is set for Anonymous access (to be done from IIS console).
As you can see, the redirection uses an absolute path, so it can be to another server.
For access denied error, you can customize it with SharePoint PowerShell commands:
$webApp = Get-SPWebApplication http://sharepoint2013
$webApp.UpdateMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied,"_layouts/15/Error/AccessDenied.html")
$webApp.Update()
Notes:
- The file "Error/AccessDenied.html" has to be under "_layouts/15" (i.e.
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\template\layouts) on all servers in the farm. The only recommended way to achieve this is to provision this file with a WSP package.
- The PowerShell commands cold be issued as C# from a feature event receiver (scoped at Web application). That feature would be embeded in the same WSP.
- To revert back to default configuration, use:
$webApp = Get-SPWebApplication http://sharepoint2013
$webApp.UpdateMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied,$null)
$webApp.Update()