繁体   English   中英

404 未找到,请求的 URL &lt;<url name> &gt; 在 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 添加重写规则,而其说明取决于您的网络服务器软件(Apache、nginx 等)。

nginx 示例:

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

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

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

暂无
暂无

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

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