Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to redirect a sites homepage to a subsites homepage. I can create a page from redirect page layout BUT, i want no waiting for a couple of seconds, i want immediate redirect. How can i achieve this?

share|improve this question
add comment

5 Answers 5

up vote 4 down vote accepted

It could be achieved with HTTP Redirect in IIS using IIS URL Rewrite module. This module allows to create various rule actions including redirect and request abort.

For your scenario i recommend this option because this should redirect the request faster as the redirection happens as soon as the HTTP request received by IIS.


Configuration

Let's describe how to configure Rule that redirect a sites homepage to a subsites homepage in URL Rewrite.

For example to redirect request from:

http://{ServerName}/teamsite/SitePages/Home.aspx

to:

http://{ServerName}/teamsite/itdepteamsite/SitePages/Home.aspx

the following Rule is used

enter image description here

,where

Pattern: ^(.*/)?teamsite/SitePages/home.aspx$

Redirect URL: teamsite/itdepteamsite/SitePages/Home.aspx

share|improve this answer
add comment

You can use a standard HTML redirect with a wait period of 0:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>Redirecting...</title>
    <meta http-equiv="REFRESH" content="0;url=http://www.yoururl.com">
  </head>
  <body>
  </body>
</html>

Changing the value of x in content="x;url" determines the number of seconds to wait before redirecting.

See: Redirect default.aspx or change default landing to page in _layouts folder?

and Change default site in Sharepoint foundation

share|improve this answer
    
this solution is not suitable for my case, because i will do set this redirection on any subsites created automatically. –  ozdogan Nov 14 '12 at 17:29
    
@rjcup3 fyi I just flagged your comment –  Christophe Nov 15 '12 at 1:32
add comment

Perhaps you can change the Welcome page to subsite homepage. To do this Go to Site Settings > Look and Feel -> Welcome Page

share|improve this answer
2  
Which can also be set using PowerShell : (get-spweb http://yourwebapp).RootFolder.Properties["vti_welcomepage"], or from SharePoint Designer. –  Steve B Nov 14 '12 at 15:52
    
this solution is not suitable for my case, because i will do set this redirection on any subsites created automatically. –  ozdogan Nov 14 '12 at 17:25
add comment

this solution is not suitable for my case, because i will do set this redirection on any subsites created automatically.

Only one way to go then. You'll have to create an EventReciever which will trigger on WebProvisioned. The code will run every time a new subsite is created. You can find quiet a lot of information regarding this on Google.

Update

public override void WebProvisioned(SPWebEventProperties properties)
{
    SPWeb currentWeb = properties.Web;
    if (PublishingWeb.IsPublishingWeb(currentWeb))
    {
        PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(currentWeb);
        //Get the file name
        SPFile welcomeFile = currentWeb.GetFile(pageName);
        //Assign the new filename to the DefaultPage property
        pubWeb.DefaultPage = welcomeFile;
        //Update the Publishing Web.
        pubWeb.Update();
    }
}
share|improve this answer
    
thank you, that was really helping. and what to do in webprovisioned event? –  ozdogan Nov 15 '12 at 8:14
1  
@ozdogan Please check my updated answer. –  Daniel Ziga Nov 15 '12 at 8:39
    
thanks. and something more, what will be the myhomepage.aspx ? is it a page created from "redirect page layout" or some aspx file containing the redirection html tags? –  ozdogan Nov 15 '12 at 15:02
    
@ozdogan I'd say a Redirect Page Layout" as they are ment for that purpose :) –  Daniel Ziga Nov 15 '12 at 17:24
    
thanks but you miss something. i want immediate redirection. in redirect page layout, it waits for 5 seconds. –  ozdogan Nov 15 '12 at 17:31
add comment

You can do this to :

http://forum.forumactif.com/t327784-redirection-immediate

Have a good day

share|improve this answer
    
you might consider link to an English page. There are some serious researches pointing out that there are some people who still does not speak French... –  itsho Jun 26 at 5:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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