1

Within SharePoint 2013, I have created several custom pages and have modified each of their "advanced" share with settings, so that each of these pages has unique permissions based on what role you are. I have successfully logged in with specific user account that has a specific role type, and tested what SharePoint will do when this user tries to access a page they do not have permissions for. SharePoint redirects this user to a page that says the following message...

"Sorry, this site hasn't been shared with you."

But is there any way I can set the redirect to a page my choosing? Such as back to my home page?

Thanks for any advice!

6
  • good question! I would say use CEWP but I'm not sure that would even get hit. Maybe a custom HTTP Handler in VS would work Commented Nov 26, 2014 at 19:43
  • man it would be so nice if there were redirect options for this under page share settings, ahhhhh!
    – klewis
    Commented Nov 26, 2014 at 19:45
  • right! Seems like it should be OOB, I'm going to read up because this would be useful. But at the same time users may get confused without a warning letting them know. Maybe not for your situation Commented Nov 26, 2014 at 19:48
  • Oh, what you could did is modify AccessDenied.aspx and put a link on the bottom like 'Return to Home page'. Even read the Query string to only display it if it matches a specific page Commented Nov 26, 2014 at 19:49
  • what would be a good way to access and brand that page without breaking any OOTB components associated to that page? I simply want to overlay the look and feel, and also apply links for the user to go back home if they do encounter that page.
    – klewis
    Commented Nov 26, 2014 at 20:05

1 Answer 1

3

I can't believe I'm doing this, it is by no means support and could be overwritten anytime if you push an update, but here is a solution I developed for you. Open AccessDenied.aspx in the _layouts folder.

In 'PlaceHolderPageTitleInTitleArea', place a div with a message indicating the user will be redirected to the homepage

   <div style='display:block'>You will be redirected to the homepage in 3 seconds...</div>

In 'PlaceHolderAdditionalPageHead' add the script block to redirect them:

<script>
  window.setTimeout(function(){
      window.location.href = "http://www.yourSPsite.ca";
  }, 3000);
</script>

It is possible to detect the page by the 'Source' QueryString and perform the redirect accordingly.

This is a quick HACK! If you want to do it right, do some research on modifying resx files, or developing a custom error page:

http://blog.randomdust.com/index.php/2013/07/custom-access-denied-page-in-sharepoint-2013/

https://social.msdn.microsoft.com/Forums/sharepoint/en-US/5c40d604-bdb4-405a-88d6-a0d3b4eb0af1/how-to-set-custom-access-denied-pages-in-sharepoint-2013

enter image description here

3
  • It may be even better to add the script in the error15.master Commented Nov 26, 2014 at 20:51
  • Thank you bro! Let me play with this next week and get back with you. thanks again! +1 on the work!
    – klewis
    Commented Nov 26, 2014 at 21:10
  • NP man, good luck, update when you can Commented Nov 26, 2014 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.