14

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?

2
  • 3
    My experience is that the Redirect layout is immediate for end users who do not have edit rights to the page. Is this not the case?
    – user39209
    Commented Jun 3, 2015 at 21:21
  • 1
    What access rights do you have? Are you an end user with edit privleges? Do you have access to the farm's server? Or somewhere in between?
    – ShooShoSha
    Commented Sep 8, 2017 at 17:31

5 Answers 5

12

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

2
  • 1
    Where do I find this setting? How would I go about adding these settings?
    – Aks
    Commented Dec 15, 2016 at 11:56
  • 1
    +1 for server redirect as the request cannot be handled any sooner.
    – ShooShoSha
    Commented Sep 8, 2017 at 17:30
8

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

2
  • this solution is not suitable for my case, because i will do set this redirection on any subsites created automatically.
    – ozdogan
    Commented Nov 14, 2012 at 17:29
  • @rjcup3 fyi I just flagged your comment
    – Christophe
    Commented Nov 15, 2012 at 1:32
3

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();
    }
}
5
  • thank you, that was really helping. and what to do in webprovisioned event?
    – ozdogan
    Commented Nov 15, 2012 at 8:14
  • 1
    @ozdogan Please check my updated answer.
    – user2536
    Commented Nov 15, 2012 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
    Commented Nov 15, 2012 at 15:02
  • @ozdogan I'd say a Redirect Page Layout" as they are ment for that purpose :)
    – user2536
    Commented Nov 15, 2012 at 17:24
  • thanks but you miss something. i want immediate redirection. in redirect page layout, it waits for 5 seconds.
    – ozdogan
    Commented Nov 15, 2012 at 17:31
2

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

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

Another cool solution I found is this:

Changing the Timeout Value for a SharePoint Redirect Page

Short: Make a copy of the Redirect Page Layout and change the "SecondsBeforeRedirect" attribute from 5 to 0 in the source code

<PublishingWebControls:RedirectControl SecondsBeforeRedirect="0" runat="server"/>

This solution also has a latency time sadly

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.