MSM 5站点设置与常见的404页面重定向

W3b*_*Guy 9 expressionengine http-status-code-404

所以我正在一个主要有4个子域的网站上工作.他们已经拥有MSM许可证,所以我用它来打破潜艇.

我的问题是:

处理所有网站的404重定向的最佳方法是什么?我想为主站点和所有子域使用通用的404页面.

在主站点上,这很容易.

{if no_results OR segment_3!=""}
    {redirect="404"}
{/if}
Run Code Online (Sandbox Code Playgroud)

但是,如果我只是添加以下内容,其他网站是否只会为分析注册页面视图:

{if no_results OR segment_3!=""}
    {embed="default_site:_includes/404"}
{/if}
Run Code Online (Sandbox Code Playgroud)

我希望能够在网站上获得相同的结果并捕获所有404个统计数据.

谢谢,Brian

W3b*_*Guy 6

好的,我最终得到的是以下内容:

我在每个站点中创建了一个"_includes"模板组.然后,我在每个网站的模板组中创建了一个模板"404-Page".(这实际上只是为了便于记忆.它们可以在任何模板组中,你想要的模板配置)

其中每一项都包含以下内容:

{embed="default_site:_includes/404-Page"}
Run Code Online (Sandbox Code Playgroud)

然后在每个站点下,在:Design => Templates => Global Preferences

我将网站设置为"启用严格网址"="是"和"404网页"="_includes/404-Page"

我在发送的标题中检查了这个,它触发404罚款.我遇到的一个问题是在IIS7下的Windows服务器上运行.我还必须在web.config文件中禁用404错误并处理自定义404代码,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Custom" existingResponse="Replace">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" path="/index.php/_includes/404-Page.html" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我将此web.config文件放在每个站点的根文件夹中.作为路径命名相同,这是一个简单的粘贴/转储.

我希望这有助于其他人.;)