开发者

404 errors being redirected to the homepage instead of custom 404 page

I have a site hosted on an Apache server. I have created some custom error pages and the following text at the top of my .htaccess file:

ErrorDocument 404 404.html

ErrorDocument 500 500.html

ErrorDocument 401 401.html

I have also tried,

ErrorDocument 404 /404.html

开发者_如何学运维ErrorDocument 500 /500.html

ErrorDocument 401 /401.html

Both the htaccess file and the custom pages are in the root directory of the server. The problem is that when I enter a garbage url (where I would expect to see my custom 404 page) I'm simply being redirected to my index page.


Try if your server is properly set up to parse and process .htaccess files in the first place (i.e., check if AllowOverride + AccessFileName directives are correct). For example, write some stuff in that you know will work and look if it actually gets executed (like a ridiculous rewrite rule). Also, look up your httpd log files for errors.

If it does get executed properly, the problem might be that your server is setup not to allow all kinds of overrides with .htaccess files. Your syntax however, is basically correct.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜