简体   繁体   English

Wordpress 帖子页面得到 404 但主页有效

[英]Wordpress post page get 404 but Homepage works

I already red a lot about this problem, but non of the solutions helped me out.我已经对这个问题很感兴趣,但是没有一个解决方案能帮助我解决问题。 I installed a fresh Wordpress on my Apache. After changing the permalink structure from default (www.domain.com/?p=id) to another one, wordpress delivers me an 404 error for each page except the homepage.我在我的 Apache 上安装了一个新的 Wordpress。将永久链接结构从默认 (www.domain.com/?p=id) 更改为另一个后,wordpress 为我提供了除主页以外的每个页面的 404 错误。

I already checked the following:我已经检查了以下内容:

  • mod_rewrite is installed and enabled (checked through phpinfo) mod_rewrite 已安装并启用(通过 phpinfo 检查)
  • .htaccess is read- and writable .htaccess 可读写

Here is my default .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

Using the plugin "Debug this", I could also find out, that the rewrite rule always deliveres additional index.php?使用插件“Debug this”,我还可以发现,重写规则总是提供额外的 index.php? at the beginning.一开始。 Eg sitemap_index\.xml$ is rewrited as index.php?sitemap=1例如sitemap_index\.xml$被重写为index.php?sitemap=1

What can I do so solve the problem?我该怎么做才能解决问题? Default links like www.domain.com/?p=1 but that kills all my SEO.像 www.domain.com/?p=1 这样的默认链接,但这会扼杀我所有的 SEO。

Edit: After the installation, there was also /index.php/%postname% written in the custom permalink.编辑:安装后,自定义永久链接中还写入了/index.php/%postname% But this setting is also returning a 404.但是这个设置也会返回 404。

open this file 打开这个文件

/etc/apache2/apache2.conf

chnage all AllowOverride None to AllowOverride All and restart your apache after that update yout permalink structure to post and update it. chnage all AllowOverride None到AllowOverride All,并在更新您的永久链接结构后重新发布您的Apache以发布和更新它。

path can be different from "/etc/apache2/apache2.conf" 路径可以不同于“ /etc/apache2/apache2.conf”

In my Ubuntu server VirtualBox VM this problem was caused by apache2 not having the rewrite mod enabled.在我的 Ubuntu 服务器 VirtualBox VM 中,此问题是由apache2未启用rewrite模块引起的。 What I did:我做了什么:

  1. sudo a2enmod rewrite to enable mod-rewrite. sudo a2enmod rewrite以启用 mod-rewrite。
  2. In /etc/apache2/apache2.conf inside the <Directory> entry for my folder I changed/etc/apache2/apache2.conf我的文件夹的<Directory>条目内我改变了
  • This: AllowOverride None这个: AllowOverride None
  • To this: AllowOverride FileInfo为此: AllowOverride FileInfo
  1. sudo service apache2 restart

And now I can permalink.现在我可以永久链接了。 Shoutout to the thousands of people saying just click save settings on your permalink page to fix the 404向成千上万的人大喊大叫,说只需单击永久链接页面上的保存设置即可修复 404

go to your permalink settings and change the permalink structure to "post name" and update your permalink structure. 转到您的永久链接设置,并将永久链接结构更改为“帖子名称”,并更新您的永久链接结构。 hope it will help. 希望会有所帮助。

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

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