简体   繁体   English

错误文档未重定向到自定义 404 页面

[英]Errordocument not redirecting to custom 404 page

So I have a website and I want it to redirect to a custom 404 page I made when it gets a 404 status, so this is inside my .htaccess file:所以我有一个网站,我希望它在获得 404 状态时重定向到我创建的自定义 404 页面,所以这是在我的.htaccess文件中:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
Options -Indexes
ErrorDocument 404 https://domainname.com/404.html

Which also contains code to remove the extensions to be able to go to a page like this domain/file without having to specify the trailing extension and Options -Indexes to disable directory browsing.其中还包含删除扩展名的代码,以便能够将 go 转到类似此domain/file的页面,而无需指定尾随扩展名和Options -Indexes以禁用目录浏览。 Now when I go on a page that does not exist I get this page:现在,当我在一个不存在的页面上 go 时,我得到了这个页面:

(PS: I'm using brave browser thus the presence of the wayback machine prompt) (PS:我用的是勇敢的浏览器,所以会有回路机提示)

页 and this status:和这个状态:

Failed to load resource: the server responded with a status of 404 ()

But it does not redirect to my 404 page as specified in my .htaccess file .但它不会重定向到我的.htaccess file中指定的 404 页面。

Any idea?任何想法?

Thanks in advance.提前致谢。

I fixed it by adding我通过添加来修复它

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

and replaced Options -Indexes by Options All -indexes .并将Options -Indexes替换为Options All -indexes to the top of .htaccess file..htaccess文件的顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM