不存在的文件未被重定向到我的自定义404页面。 在本地服务器上正常工作

The below is my .htaccess file placed in the root

ErrorDocument 404 http://www.abc.com/404.php Redirect /services/something.php http://www.abc.com/index.php

The second line is irrelevant I guess.

The problem is that it redirects any non existent file to my 404.php perfectly when I run it in my local WAMP server. But with the same is not happening when I upload it to my server. What could be wrong?

Also, if I write

ErrorDocument 404 /404.php instead of ErrorDocument 404 http://www.abc.com/404.php it won't even work in the localhost.

I get the error message saying

The requested URL /abc/xxxx was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Why does this error occur when every website I refer has recommended ErrorDocument 404 /404.php

first of all make sure that the 404.php is present in the proper location and http://www.abc.com/404.php is working properly.

if both 404.php and .htaccess are present in the same root folder, then try changing following line in .htaccess file

ErrorDocument 404 /404.php 

to

ErrorDocument 404 /root/404.php