Kentico/ASP.NET ResponseRedirect 仍然保持初始 URL
Kentico/ASP.NET ResponseRedirect still keeps initial URL
我的 web.config 设置如下:
<customErrors mode="RemoteOnly" redirectMode="ResponseRedirect" defaultRedirect="~/SpecialPages/PageNotFound.aspx">
<error statusCode="404" redirect="~/SpecialPages/PageNotFound.aspx" responseMode="Redirect"/>
</customErrors>
但是当用户访问 mysite.com/gibberish 时,我的 404 页面出现了,但是 url 仍然是 mysite.com/gibberish,但我希望它显示 mysite。 com/SpecialPages/PageNotFound。我还缺少其他东西吗?
我正在使用 Kentico10 CMS(如果这有什么不同的话),但我也一直在遵循他们的说明。好像我在服务器端遗漏了一些东西。
您是否在 Kentico 中指定了 Page not found
?如果是这样,请删除该配置,因为您不希望 Kentico 为您处理错误,然后您在 web.config 中的自定义错误应该像您在任何其他项目中设置的那样工作。
以防有人阅读我从 kentico 自己那里得到了答案:
This behavior is correct from SEO point of view. Previously we had the
behavior you wanted but it was really bad for SEO to do a redirection
so it was changed and just the 404 status code is returned and the URL
is the same. If you want to change this behavior, you can create
custom event handler and in the request end event check the status
code and if it is 404, do a redirection - but this can harm your SEO
rankings.
我的 web.config 设置如下:
<customErrors mode="RemoteOnly" redirectMode="ResponseRedirect" defaultRedirect="~/SpecialPages/PageNotFound.aspx">
<error statusCode="404" redirect="~/SpecialPages/PageNotFound.aspx" responseMode="Redirect"/>
</customErrors>
但是当用户访问 mysite.com/gibberish 时,我的 404 页面出现了,但是 url 仍然是 mysite.com/gibberish,但我希望它显示 mysite。 com/SpecialPages/PageNotFound。我还缺少其他东西吗?
我正在使用 Kentico10 CMS(如果这有什么不同的话),但我也一直在遵循他们的说明。好像我在服务器端遗漏了一些东西。
您是否在 Kentico 中指定了 Page not found
?如果是这样,请删除该配置,因为您不希望 Kentico 为您处理错误,然后您在 web.config 中的自定义错误应该像您在任何其他项目中设置的那样工作。
以防有人阅读我从 kentico 自己那里得到了答案:
This behavior is correct from SEO point of view. Previously we had the behavior you wanted but it was really bad for SEO to do a redirection so it was changed and just the 404 status code is returned and the URL is the same. If you want to change this behavior, you can create custom event handler and in the request end event check the status code and if it is 404, do a redirection - but this can harm your SEO rankings.