Using Set-SPCustomLayoutsPage command you can set the custom access denied page.
Following are the steps:-
- Log into one of the farm WFEs as a farm administrator.
- Open Windows Explorer, and then navigate to this folder:-C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\
- Add a subfolder to this folder, naming it CustomPages.
- In the LAYOUTS folder copy the file AccessDenied.ASPX into the CustomPages subfolder, renaming it AccessDeniedNew.ASPX.
- Modify AccessDeniedNew.ASPX as desired. To add text or other HTML elements to this page, be sure to introduce them within asp:Content tags. In the example below, formatted text has been added so that it will appear just below the "Sorry, this site..." message.
- After completing the modification on this WFE, copy the CustomPages subfolder into the LAYOUTS folder of each of the WFEs in your farm.
- Execute the command that will update the farm configuration database to point to the new location of the AccessDenied page:
- The Access Denied page path is now updated.
- Perform the IIS Reset activities in all the servers.