.htaccess错误:无法使用html和php重定向显示自定义400404500错误页面

.htaccess错误:无法使用html和php重定向显示自定义400404500错误页面,.htaccess,custom-error-pages,.htaccess,Custom Error Pages,我的.htaccess中有一段代码,应该是www.mysite.com/page.html或www.mysite.com/page.php,只显示www.mysite.com/page。此代码似乎干扰了重定向到我创建的自定义错误页的其他代码。我在另一台服务器上测试了它,发现我的代码可以单独工作,但不能一起工作 RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI

我的.htaccess中有一段代码,应该是www.mysite.com/page.html或www.mysite.com/page.php,只显示www.mysite.com/page。此代码似乎干扰了重定向到我创建的自定义错误页的其他代码。我在另一台服务器上测试了它,发现我的代码可以单独工作,但不能一起工作

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+).* $1.html

<-- this is what i added below and it doesnt work with the code abouve, 
however it does work when the only code in the htaccess file-->

ErrorDocument 400 /400.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml
重新编写引擎打开
重写条件%{HTTPS}关闭
重写规则^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}\.php-f
重写规则^(.*)$$1.php
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^([^/]+).$1.html
错误文档400/400.shtml
错误文档404/404.shtml
错误文档500/500.shtml
像这样尝试:

ErrorDocument 400 /400.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...
ErrorDocument指令应首先出现。还需要注意的是,您需要错误脚本的绝对路径,例如
/home/web/404.shtml
http://example.com/404.shtml