简体   繁体   English

404路由问题-AWS Linux / Wordpress网站

[英]404 routing issue - AWS Linux / Wordpress site

We are running a WordPress site on a AWS EC2 Linux instance and have created custom 403 and 404 error files (both html files). 我们正在AWS EC2 Linux实例上运行WordPress站点,并创建了自定义的403和404错误文件(均为html文件)。 The files are located in the root of the website. 这些文件位于网站的根目录中。

The root .htaccess file has been amended to include the following section: 根.htaccess文件已被修改为包括以下部分:

# Custom Documents

ErrorDocument 403 /403.html

ErrorDocument 404 /404.html

The site uses a theme and within this there is a 404.php file. 该网站使用主题,其中包含一个404.php文件。 The problem is that any 404 requests are being routed to this file instead of the 404.html file. 问题在于,所有404请求都将被路由到该文件而不是404.html文件。

The httpd.conf file has all access set for the root folder var/www/html so there's nothing in it that I can see that would be blocking the .htaccess file. httpd.conf文件已为根文件夹var / www / html设置了所有访问权限,因此其中没有任何内容可以阻止.htaccess文件。 As a double check I added some 301 redirects into the .htaccess file just to check if they were getting hit and they were working. 作为仔细检查,我在.htaccess文件中添加了一些301重定向,只是为了检查它们是否被击中以及它们是否在工作。

Also checked if there were any other .htaccess files which might be overriding the one in , there were some in a plugin but from what I can see they shouldn't have any impact. 还检查了是否还有其他.htaccess文件可能会覆盖其中的一个文件,插件中还有一些文件,但是从我的眼中看,它们应该没有任何影响。

Is there anything else which could be overriding the .htaccess file? 还有什么可能会覆盖.htaccess文件吗?

ErrorDocument 404 doesn't work in Wordpress like regular pages. ErrorDocument 404在Wordpress中无法像常规页面一样工作。 Wordpress by default shows 404.php content from inside your selected theme. 默认情况下,WordPress会从所选主题内部显示404.php内容。 You can put your custom code in that 404.php file. 您可以将自定义代码放在该404.php文件中。

Here is official Wordpress guide for Creating an Error 404 Page 这是用于创建错误404页面的官方Wordpress指南

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

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