使用.htaccess重定向到404错误的php/html文件

Pro*_*raz 5 .htaccess

我想将所有404错误重定向到"404.php".

我尝试使用ErrorDocument 404 /404.php.htaccess,但没有运气,也许我的其他规则不允许这种方式,我不太确定,因为我无法在www上找到此信息.

如果有人知道如何解决这个问题,请大声呼喊:P

我现在的.htaccess

#### pie thingy ####
AddType text/x-component .htc

#### Rule for Error Page - 404 ####
ErrorDocument 404 /404.html

#### url rewriting ####
Options +FollowSymlinks
RewriteEngine on

#### REDIRECT IF NO SUB-DOMAIN ####
RewriteCond %{HTTP_HOST} ^([^.]+)\.([^.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1.%2/$1 [R=301,L]

#### Remove "www." from any subdomain requests ####
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.precisehire\.com [NC]
RewriteRule (.*) http://%1.precisehire.com/$1 [R=301,L]

#### Rules for rewriting from PHP to HTML with fallback ####
RewriteCond %{REQUEST_URI} ^/(.*)\.html$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)\.html$ $1.php [nc]
Run Code Online (Sandbox Code Playgroud)

Pro*_*raz 12

通过放置错误文档的完整URL解决.

例:

#### Rule for Error Page - 404 ####
ErrorDocument 404 http://www.domain.com/404.html
Run Code Online (Sandbox Code Playgroud)