Skip to content

Instantly share code, notes, and snippets.

@robearlam
Last active April 15, 2017 01:19
Show Gist options
  • Save robearlam/a48a3b903657648df728b1162fb1d016 to your computer and use it in GitHub Desktop.
Save robearlam/a48a3b903657648df728b1162fb1d016 to your computer and use it in GitHub Desktop.
Sitecore Multisite 404, 500 & Robots.txt
HttpContext.Current.Response.StatusCode = 404;
<add type="Contains" match="~/media/" />
<add type="Contains" match="~/icon/" />
<add type="Contains" match="~/link.aspx" />
<add type="StartsWith" match="/sitecore" />
<add type="Contains" match=".asmx" />
<add type="Contains" match=".ashx" />
public void Application_Error(object sender, EventArgs args)
{
Sitecore.MultisiteHttpModule.Errors.ErrorHandler.HandleError(Server.GetLastError());
}
PM> Install-Package Sitecore.MultisiteHttpModule
<httpRequestBegin>
<processor type="Sitecore.MultisiteHttpModule.NotFound.NotFoundHandler, Sitecore.MultisiteHttpModule" patch:after="processor[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']" />
</httpRequestBegin>
<site name="MySite"
...
notFoundPageId="{BFA65433-4552-4507-9375-C96137287640}"
errorPagePath="/errors/MySite.html"
robotsTxtLocation="/robots/MySite.robots.txt" />
<configSections>
<section name="multisiteHttpModule" type="Sitecore.MultisiteHttpModule.Configuration.MultisiteHttpModuleSettings, Sitecore.MultisiteHttpModule" />
</configSections>
<multisiteHttpModule defaultErrorPage="/error.html" errorsEnabled="True" notFoundEnabled="True">
<exclude404Rules>
<add type="Contains" match="~/media/" />
<add type="Contains" match="~/icon/" />
<add type="Contains" match="~/link.aspx" />
<add type="StartsWith" match="/sitecore" />
<add type="Contains" match=".asmx" />
<add type="Contains" match=".ashx" />
</exclude404Rules>
</multisiteHttpModule>
<system.webServer>
<handlers>
<add name="RobotsHandler" path="/robots.txt" verb="GET" type="Sitecore.MultisiteHttpModule.Robots.RobotsHandler, Sitecore.MultisiteHttpModule" />
</handlers>
</system.webServer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment