错误文档 404 /404.html 在 APACHE 中的 .htaccess 文件中不起作用



mydomain.pe 在带有 Apache 的 Linux 服务器上,我在.htaccess的 RewriteEngine 下添加了以下行ErrorDocument 404 /404.html

但是,在进行虚假网址测试时:默认情况下,abc.mydomain.pe/etc.html 会向我抛出 404 错误。

我的 404.html 文件可通过网络在网址中看到:abc.mydomain.pe/404.html

请大家支持,我有时间,我无法在我身边解决。

这可能发生吗?我分享我的.htaccess文件:

<IfModule mod_rewrite.c>
RewriteEngine on
ErrorDocument 404 /404.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^(.*)$ $1.html
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.abc.mydomain.pe/$1 [R,L]
RewriteCond %{HTTP_HOST} !^www.abc.mydomain.pe$ [NC]
RewriteRule ^(.*)$ https://www.abc.mydomain.pe/$1 [L,R=301]
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* ? [F,L]
Options -Indexes
</IfModule>

<IfModule mod_headers.c>
<FilesMatch ".(js|css|xml|gz|html)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
<IfModule mod_deflate.c>
<filesMatch ".(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
ExpiresByType text/javascript "access 1 month"
</IfModule>
## EXPIRES CACHING ##
## INICIO compresión gzip (mod_deflate)
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/shtml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule> 
## FIN compresión gzip (mod_deflate)##
# php -- BEGIN cPanel-generated handler, do not edit
# Configure el paquete “ea-php56” como el lenguaje de programación predeterminado “PHP”.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

如果您的域 mydomain.pe,那么您的错误文档可能位于错误的位置,正如您所说的那样abc.mydomain.pe/404.html

也许你应该将文件404.html复制到mydomain.pe/404.html,因为Apache会在那里寻找它。它应该可以通过 mydomain.pe/404.html 而不是通过 abc.mydomain.pe/404.html

我已经能够使用"错误页面"通过cPanel面板修复它,这很奇怪,我注意到创建了一个404.shtml文件(添加了" s"(,这对我来说是新事物,也许EasyApache 4现在也可以工作。

感谢您的阅读, 阿克塞尔·

最新更新