开发者

I have configured 404 to redirect to homepage under IIS 7 but it doesn't work

开发者 https://www.devze.com 2023-03-21 05:23 出处:网络
I have used IIS 404 control panel and it adds this in web.config <system.web> <customErrors>

I have used IIS 404 control panel and it adds this in web.config

<system.web>
    <customErrors>
        <error redirect="http://mydomain.com" statusCod开发者_如何学运维e="404" />
    </customErrors>
</system.web>

But when I test http://mydomain.com/anythingstupid It stills shows 404 not my homepage why ? Note: I have a wordpress blog hosted at that domain.


What happens if you use tilde slash instead? (sorry no tilde symbol on phone keypad)


I don't know about IIS here but technically a 404 is not a redirect and not supposed to redirect! A user-agent that receives a 404 error shows the page it receives with the submitted status code.

So if this <error redirect="http://mydomain.com" /> tag is an instruction element to IIS to show a certain page it is a little bit weird because IIS should have an internal reference and not an external reference. I may redirect (3xx) to an external page but I don't show an error message from another domain.

So without even knowing this IIS config I'd say that the redirect attribute itself is the wrong one or you have to write something more like this redirect="/index.html"

0

精彩评论

暂无评论...
验证码 换一张
取 消