Redirect a SharePoint site by using the Content Editor Web Part
Author: Devin Walker
DLOCC, Inc.
This blog demonstrates a useful way to use the Content Editor Web Part to redirect users of a particular site. The script prompts a site’s end users they will be redirected and then redirects them after a certain period of time.

At some point in time you might want to point users to another location from a specific page and prompt them before doing so. I will show you how to do this using the Content Editor Web Part. It is rather easy. First, you must have proper permissions on the page or site that you are trying to redirect users. Second, be advised that this may not be best practice to use the CEWP. For my situation, I needed a way to direct users from a page without actually moving or deleting the page. This worked great for my needs, yours may be different. Anyways here we go:
- First click Site Actions > Edit Page in the top right section of your browser window. Now MOSS will effectively checkout the page in your account name.
- Next we are going to add the Content Editor Web Part to a zone of your choice; it doesn’t really matter since users won’t be using the page. This is done several ways, let’s just click on the Add a Web Part button ontop of the zone you chose.
- This will bring up the Add a Web Part window. Scroll down to the Content Editor Web Part.
- This will place the CEWP into the Top Zone or whichever zone you added it to. Let’s modify the web part. This is done by clicking Edit > Modify Shared Web Part.
- Once we have clicked the modify button a window opens on the right hand side of the browser with various options for the web part. We want to add our code the webpart so we will click the Source Editor… button.
- Good, almost done… we just need to copy and paste the following code:





<SCRIPT type='"text/javascript"'>// <![CDATA[ alert("This site has been moved to another location, please update all existing bookmarks. You will be redirected momentarily."); // ]]></SCRIPT>
Into the Source Editor Windows that pops up when we clicked the Source Editor… button.

Great! Now all you have to do is click the Save button, publish the page and your done. Users who navigate to this page will be greeted with a popup and redirected in 10 seconds (the default time). Please note: If you want to change the amount of time before the redirect simply change the number of seconds by editing the following number representing the time lapse:
<meta http-equiv="refresh" content="10;url=http://MYSERVERNAME.com/Pages/default.aspx">
If you want a webpart with some more functionality then check out the SharePoint Redirect Webpart
Author: Devin Walker
DLOCC, Inc.
About: Devin Walker is a professional web designer, SharePoint enthusiast and founder of the consulting company DLOCC, Inc.. Devin has years of experience working with companies of all sizes to successfully implement, test and launch SharePoint enterprise content management systems. He writes about his experiences on his blog: DLOCC | Articles and Tutorials
- How to remove the “title” column from a SharePoint list
- SharePoint Errors, Warnings and Problems Collection
- Link Two Lists and Display the Data Using the SharePoint Data View
- SharePoint Workflow Time Zones
- Redirect a SharePoint site by using the Content Editor Web Part
- How to Move SharePoint Calendars Fast
- Style a Page using the Content Editor Web Part and CSS
So easy even I can do it!! Thanks Devin, more of this cool easy stuff in CEWP’s please.
You’re welcome : ]
Kevin, I am surprised that as a professional Web designer you suggest to put a meta tag inside the body of a Web page, which AFAIK is against Web standards. Please correct me if I’m wrong.
There are other ways to do redirects. You can use the window.location.href property for that.
[sorry for the typo in your name btw]
Christophe,
I am well aware of this an mention that when using this method to “be advised that this may not be best practice” and I fail to see how using it for this purpose would cause any harm. You do bring up a valid point that there are a lot of other ways to do redirects. This is just the method I chose when writing this article.
@Christophe
Con you describe the approach using the window.location.href property for the End User (i.e. me…)
J
Off the top of my head: instead of using the meta tag, change the script to this:
alert(”This site has been moved to another location, please update all existing bookmarks. You will be redirected momentarily.”);
window.location.href = “http://MYSERVERNAME.com/Pages/default.aspx”;
It’ll be a little more complicated if you need a countdown.
Also, a side note: keep in mind the ?contents=1 trick, as after you include a redirect it will become difficult to edit the page.
I get the redirect but I don’t get the pop up. I’ve done the idiot checks on my MOSS 2007 publishing site and still can’t figure out why no pop up.
A related question…I think.
We have a Sharepoint site (WSS 3.0), where the user created a redirect on the default.aspx (i’m not sure exactly how they did it, so it may not be the same method you described). Our problem is that we want to stop the redirect. However, we can’t get in to edit the web parts … it keeps redirecting us on the “edit this page” screen. We tried to use the “reset site definition” on that page, but it doesn’t seem to do anything…Any ideas? Thanks.
Mike, that’s exactly the issue I mentioned in my earlier comment.
If the redirect has been added through a Web Part, append ?contents=1 to the URL and this will send you to the maintenance page.
If not, you’ll need to look at the source code (for example using SharePoint Designer).
Hi i have redirected my sharepoint home page by using source editor and adding the script you mentioned. I have included contents=1, so it redirects in 1 second to a different page. I want it to change back to 10. By the time I click on edit page it redirects. How can I change the time in the script now. Thanks for your help.
I get the redirect but, not the pop up alert…using WSS 3.0…help.
Hi i have redirected my sharepoint home page by using source editor and adding the script you mentioned. I have included contents=1, so it redirects in 1 second to a different page. I want it to change back to 10. By the time I click on edit page it redirects. How can I change the time in the script now. Thanks for your help.
_______________________________________________________________________________
1 second was enough for closing the webpart, you ve to be very quick. So, I closed the webpart and created a new one with time to redirect in 4 seconds. Don`t make the time to be zero, otherwise you cannot get to the page and edit it.
Can you just disable Java in your browser (method varies from browser to browser). Then the redirect can’t fire, and you can edit at will.
Do a quick google search on “disable javascript IE 6″ or whatever browser and version you have.
Hey thanks for posting this. I needed it quick and functional and this is it! I sincerely appreciate it.