我从 Stackoverflow-> 一个重新处理 Sitecore 中的自定义 404 的博客中获取了以下代码(它实际上将 302 重定向到状态为 200 的 404 页面,谷歌将其作为软 404 获取)。
虽然这在我们的本地测试服务器上工作得很好,但当我们将它投入生产时,网站就会出现问题,并且需要 AGES 时间,例如 8-9 分钟来加载和填充。
public class ExecuteRequest : Sitecore.Pipelines.HttpRequest.ExecuteRequest
{
    protected override void RedirectOnItemNotFound(string url)
    {
        var context = System.Web.HttpContext.Current;
        try
        {
            // Request the NotFound page
            var domain = context.Request.Url.GetComponents(
                UriComponents.Scheme | UriComponents.Host, 
                UriFormat.Unescaped);
            var content = WebUtil.ExecuteWebPage(
                string.Concat(domain, url));
            // The line below is required for IIS 7.5 hosted 
            // sites or else IIS is gonna display default 404 page
            context.Response.TrySkipIisCustomErrors = true;
            context.Response.StatusCode = 404;
            context.Response.Write(content);
        }
        catch (Exception ex)
        {
            Log.Error(string.Format("Falling back to default redirection behavior. Reason for error {0}", ex), ex);
            // Fall back to default behavior on exceptions
            base.RedirectOnItemNotFound(url);
        }
        context.Response.End();
    }
} 
PS:然后我在 web.config 中用我的自定义替换了 ExecuteRequest。
如果您经历过类似的事情或知道任何问题,请务必说明一下。
提前致谢