404 未找到,请求的 URL <<url 名称>>在 WordPress 的此服务器上找不到


404 not found , the requested URL <<url name>> not found on this server in wordpress

我最近安装了wordpress,当我尝试更改永久链接格式时遇到问题,

当我将永久链接从默认值更改为日期和时间时

 Default    http://127.0.0.1/?p=123
 Day and name   http://127.0.0.1/2015/03/16/sample-post/ 

生成的链接不起作用,它给出了相同的error 404所有时间

 The requested URL /2015/03/16/post-5-problem/ was not found on this server.

但是当永久链接类型默认时,这非常有效。

我找到了一些解决方案,它们是

sudo a2enmod rewrite
Module rewrite already enabled

另一种解决方案是在将永久链接从默认更改为其他类型之前,将.htaccess文件的模式权限更改为666(授予.htaccess文件的wordpress写入权限),

sudo chmod 666 /address_of_.htaccess 

我检查了 .htaccess 文件

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

但以上似乎是正确的,上面由wordpress本身包含

这两种解决方案似乎都不起作用,我还需要更改其他内容才能启用永久链接选项吗?

如果是全新安装的Web服务器,则默认情况下可能不允许使用.htaccess规则。要解决此问题,请编辑 httpd.conf(通常它在/etc/apache2 中),找到

<Directory "path/to/your/document/root">    
    # ....
     AllowOverride None
    # ....
</Directory>

和改变

AllowOverride None

AllowOverride All

然后重新启动 Web 服务器并重试。

从wordpress管理区域重置所需的永久链接,并在htaccess中添加以下代码:

# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

现在,检查博客文章和页面。

谢谢

你可以转到首选项 ->服务和端口,你需要检查已启用的 Apache ssl

它对我有用

您收到此错误是因为您的网络服务器找不到该文件,并且它没有将请求传递给 Wordpress。

您需要为WordPress添加重写规则,并且根据您的Web服务器软件(Apache,nginx等)添加重写规则

nginx的例子:

location / {
       try_files $uri $uri/ /index.php?$args;
}

字面意思是:尝试首先在文件系统中打开"/2015/03/16/post-5-problem/",如果它不存在,请尝试添加一个斜杠,如果这无助于将请求传递给索引.php(这是 Wordpress 主文件)与参数。

启用重写模块是不够的,您必须添加重写规则。