I need to custom error 404 redirection. My webconfig is:
我需要自定义错误404重定向。我的webconfig是:
<customErrors mode="On">
<error statusCode="404" redirect="~/Errors/Error404.aspx" />
</customErrors>
I will delete this page /service/reservation.aspx
and i would like when a client go to this page it will be redirected to /service/newreservation.aspx
an in other case will be redirected to /Errors/Error404.aspx
. I'm using IIS6 and wouldn' like to install any iis extension (because i have about 60 server)
我将删除此页面/service/reservation.aspx,我希望当客户端转到此页面时,它将被重定向到/service/newreservation.aspx,在其他情况下将被重定向到/Errors/Error404.aspx。我正在使用IIS6并且不想安装任何iis扩展(因为我有大约60台服务器)
How can do this please?
怎么能这样呢?
2 个解决方案
#1
1
You can set URL rewrite module and set rules for that. Instead of relying on custom error.
您可以设置URL重写模块并为其设置规则。而不是依赖于自定义错误。
Here is the link how you can install IIS rewrite module in IIS 6.
以下是如何在IIS 6中安装IIS重写模块的链接。
http://www.web-site-scripts.com/knowledge-base/article/AA-00461/0/Installation-of-URL-Rewriting-module-IIRF-for-IIS6-IIS7.html#iis56
#2
0
Since you are deleting the old page, you can set up your own javascript redirect to handle 404's:
由于您要删除旧页面,因此您可以设置自己的javascript重定向来处理404:
Set the Custom Errors in IIS6 to point to an HTML file.
将IIS6中的自定义错误设置为指向HTML文件。
In that file, write a javascript redirect:
在该文件中,编写一个javascript重定向:
<script type="text/javascript">
var url = document.URL;
if(url.match("/service/reservation.aspx$"))
{
window.location.href = "/service/newreservation.aspx";
}
else
{
window.location.href = "/Errors/Error404.aspx";
}
</script>
#1
1
You can set URL rewrite module and set rules for that. Instead of relying on custom error.
您可以设置URL重写模块并为其设置规则。而不是依赖于自定义错误。
Here is the link how you can install IIS rewrite module in IIS 6.
以下是如何在IIS 6中安装IIS重写模块的链接。
http://www.web-site-scripts.com/knowledge-base/article/AA-00461/0/Installation-of-URL-Rewriting-module-IIRF-for-IIS6-IIS7.html#iis56
#2
0
Since you are deleting the old page, you can set up your own javascript redirect to handle 404's:
由于您要删除旧页面,因此您可以设置自己的javascript重定向来处理404:
Set the Custom Errors in IIS6 to point to an HTML file.
将IIS6中的自定义错误设置为指向HTML文件。
In that file, write a javascript redirect:
在该文件中,编写一个javascript重定向:
<script type="text/javascript">
var url = document.URL;
if(url.match("/service/reservation.aspx$"))
{
window.location.href = "/service/newreservation.aspx";
}
else
{
window.location.href = "/Errors/Error404.aspx";
}
</script>