简体   繁体   English

找不到 Wordpress 永久链接 404

[英]Wordpress permalinks 404 not found

i want to modify my permalink structure to a /%postname%/ to use Buddypress on a wordpress website server.我想将我的永久链接结构修改为 /%postname%/ 以在 wordpress 网站服务器上使用 Buddypress。

After some trial, i experiencing some trouble and even with my search in different forum, i don't know how to solve it.经过一些试验,我遇到了一些麻烦,即使我在不​​同的论坛中搜索,我也不知道如何解决。

My .htaccess permission is for the trial 666 so wordpress have to modify this file, but won't (last file modify at my server installation).我的 .htaccess 权限用于试用版 666,因此 wordpress 必须修改此文件,但不会(在我的服务器安装时修改最后一个文件)。 In the database, the permalinks structure succesfully passed to %postname%.在数据库中,永久链接结构成功传递给 %postname%。

Now, i have a 404 error in all pages i want to access.现在,我想访问的所有页面都出现 404 错误。

.htaccess file : .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

I running Apache, so to force the vars selection, i modified to this in the wp-include/vars.php :我运行 Apache,所以为了强制选择 vars,我在 wp-include/vars.php 中修改了这个:

//$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
$is_apache = 1;

What i have to do now ?我现在必须做什么?

# #

EDIT : I've reinstalled it, retry to do all of this, and same problem... Apache is owner of the file so i really don't understand...编辑:我已经重新安装了它,重试做所有这些,同样的问题...... Apache 是文件的所有者,所以我真的不明白......

如果您能够访问 wp-admin 面板,那么请尝试将永久链接结构更新为“Plain”,然后检查您是否仍然收到 404 页面错误。

even I had the same issue when I deployed my wordpress site in aws ubuntu machine with apache server we have to add this lines in 000-default.conf if you have deployed your wordpress site in /var/www/html即使我在使用 apache 服务器的 aws ubuntu 机器上部署我的 wordpress 站点时也遇到了同样的问题,如果您已将 wordpress 站点部署在 /var/www/html 中,我们必须在 000-default.conf 中添加此行

    <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

then we have to restart apache server sudo service apache2 restart然后我们必须重新启动 apache 服务器 sudo service apache2 restart

Okay, i've solved the question.好的,我已经解决了这个问题。

The problem, and i haven't specified it in my problem explanation, is i use Virtualhost (i have too a monitoring website in this server so i wanted to separate all the task, logs etc...), and there is a problem with virtualhost and this instruction :问题,我没有在我的问题解释中指定它,是我使用 Virtualhost(我在这个服务器上也有一个监控网站,所以我想分离所有的任务,日志等......),并且有一个问题使用虚拟主机和此指令:

RewriteBase /

In fact, this work in normal apache environnment but not in virtualhost.事实上,这在正常的 apache 环境中工作,但在虚拟主机中无效。

So what i had to do is to move my .htaccess content on the vhost conf.d file :所以我必须做的是将我的 .htaccess 内容移动到 vhost conf.d 文件中:

<VirtualHost *:80>
    ServerAdmin nfrbezar@vdbassocies.fr
    ServerName intranet.vdb.local
    ServerAlias intranet
    
    DocumentRoot /var/www/vhosts/intranet/html

    ErrorLog /var/www/vhosts/intranet/logs/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/www/vhosts/intranet/logs/access.log combined

    <Directory "/">
       RewriteEngine On
       AllowOverride None
       Allow from 10.1.1.0/8
       
       <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
        </IfModule>

    </Directory>

</VirtualHost>

And by this way, it now work !通过这种方式,它现在可以工作了!

在此处输入图片说明

Sorry for not telling you that it was a virtualhost, i doesn't think it was important for the problem resolution, even if i supposed it was an apache problem.很抱歉没有告诉你它是一个虚拟主机,我认为这对解决问题并不重要,即使我认为这是一个 apache 问题。

According to the Wordpress permission of.htaccess should be 604. Apply this permission and check it.根据wordpress的权限.htaccess应该是604。应用这个权限,检查一下。

600 -rw-------  /home/user/wp-config.php
604 -rw----r--  /home/user/cgi-bin/.htaccess
600 -rw-------  /home/user/cgi-bin/php.ini
711 -rwx--x--x  /home/user/cgi-bin/php.cgi
100 ---x------  /home/user/cgi-bin/php5.cgi

还要确保具有必要权限的 .htaccess 位于 /var/www/html 中,即使 wordpress 安装位于不同的文件夹中

In my case it was the cache (Redis used as object cache).就我而言,它是缓存(Redis 用作对象缓存)。 After changing the permalink settings, the new URLs were used by WordPress but all resulted in a HTTP 404 Not Found error.更改永久链接设置后,WordPress 使用了新的 URL,但都导致了 HTTP 404 Not Found 错误。 Flushing the cache (eg using the WP CLI, wp @production cache flush ) fixed the issue. wp @production cache flush缓存(例如使用 WP CLI、 wp @production cache flush )修复了这个问题。

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

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