This is so easy and has so many applications within SharePoint. I’ve lost count of all the times SharePoint users have complained about being thrown at the base of a list after they close an item. Most of the time the users shouldn’t even know about the list itself- they have just accessed a news item link on a home page or something similar. So here is a solution to redirect users away from a list base that they have access to but don’t need to see:
Edit the list page and add a Content Editor web part. Edit the source and add this script:
if (window.location.search.length < 1)
window.location.href = “http://www.google.com“;
Click Ok. Now you will notice that the page does not redirect straight away. This is because the a query string (window.location.search) is present : ?PageView=Shared. If you navigate away from the list and then navigate back to it you will be redirected to Google. If you want some users to have access to the base of the list you can just provide them with the link containing a query string e.g. http://server/lists/listname/allitems.aspx?noredirect. When the web part works to your liking, you can Export the web part (Edit-> Export) and reuse it on other pages and sites.
If you end up accidentally causing a constant redirect when playing around with your script logic, just copy the list url into the address bar and then add ?contents=1 to the end and you will be able to delete the CE web part using the Web Parts maintenance page.
Update: this is a bit nicer and looks for a specific query string: ?redirect=false to prevent redirection
<script for=”window” event=”onload”>
if (window.location.search.substring(1) != “redirect=false”)
window.location.href = http://www.google.com;