I need to custom error 404 redirection. My webconfig is:
<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)
How can do this please?
You can set URL rewrite module and set rules for that. Instead of relying on custom error.
Here is the link how you can install IIS rewrite module in IIS 6.
Since you are deleting the old page, you can set up your own javascript redirect to handle 404's:
Set the Custom Errors in IIS6 to point to an HTML file.
In that file, write a javascript redirect:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.