Redirecting to a New URL in SharePoint 2010

Al of us developers learn from experience, especially when we come through a phase of escalations.

A team had the following problem early in the morning and I was dragged into helping them.

Now the problem was, they emailed a different site that they wanted to demo to the users and you need to have a quick approach in 2 minutes.

What will you do?

Q. Contact the support team?

  • They will reply in some hours.
Q. Open the server and do some configuration?
  • It is a live production server, most of us don't have access to it.

Now what?

Send the uses another email informing them we have wrongly configured the URL, please take this as a new URL. It will look bad, that was the main concern of the team. They did not want to do that.

So what did we do?

In these scenarios, first calm down please.

Secondly, here is an option.

  • Open the wrong site you have provided.

  • Edit the Home page.

    edit

  • Insert a web part.

  • Add a Content Editor web part.

    content editor

  • Edit the Content Editor web part

  • Click on HTML

    select html

  • Add these two lines of code.
Code
  1. <script '"text/javascript"'></script>  
  2. <meta http-equiv="refresh" content="0;url=http://newhome/">  
Just change the URL of the site and set the value of content to be 0, it will take 0 for the time to redirect to a new site.
  • Close the web part

  • Save the page

  • Click refresh, it will go to your new URL.

  • There will be a delay of 1 second, even if you use 0 for the content value because the web service takes time to respond on page load but it is better.

  • Hence when users click on the wrong URL, they will be diverted to your new site.

  • Mission Accomplished.

  • As I always say, keep Learning.
Cheers.