固定链接(别杀了我)拒绝工作..是的,结果是404

时间:2022-01-04 作者:Adam Larsson

是的,我读了很多页面和讨论,我尝试了很多选择,但是NONE 到目前为止一直在工作!

我正在用WordPress运行自己的apache2服务器,何时从/?page\\u id=xxx到其他(帖子名称),我在制作的旧(和新)页面上得到404。

正如我之前所说,我已经做了很多测试,最后一次尝试是禁用所有插件,并使用的全新副本(新默认)。htaccess

然后我更改了设置,但没有,404。。

如果我在https://example.com/?page_id=279并更改为post name permalinks,它将显示:https://example.com/test

如果我打开https://example.com/testhttps://example.com/?page_id=279,它将重定向到https://example.com/test。。当然触发404

WordPress可以更改。htaccess。

可能是MySQL中的某些错误,甚至是apache2中的某些错误吗?

更新:这是我的虚拟配置;

SSL configuration:

<IfModule mod_ssl.c>
<VirtualHost mysite.example.com:443>
    ServerName mysite.example.com
    ServerAdmin arga@localhost
    DocumentRoot /var/www/mysite.example.com
    ErrorLog ${APACHE_LOG_DIR}/argagubben.error.log
    CustomLog ${APACHE_LOG_DIR}/argagubben.access.log combined


SSLCertificateFile /etc/letsencrypt/live/mysite.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mysite.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
Header always set Strict-Transport-Security "max-age=31536000"
</VirtualHost>
</IfModule>


http:

<VirtualHost mysite.example.com:80>
ServerName mysite.example.com
ServerAlias mysite.example.com

DocumentRoot /var/www/mysite.example.com
    <Directory /var/www/mysite.example.com>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.html index.php
        Require all granted

    </Directory>
<Directory /var/www/mysite.example.com/wp-content>
        Options FollowSymLinks
        Require all granted

    </Directory>

ErrorLog ${APACHE_LOG_DIR}/argagubben.error.log
CustomLog ${APACHE_LOG_DIR}/argagubben.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =mysite.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
这些都可以在apache2中找到。形态:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options  FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<FilesMatch "^\\.ht">
        Require all denied
</FilesMatch>
<FilesMatch "cpf.">
    Require all denied
</FilesMatch>

1 个回复
最合适的回答,由SO网友:kero 整理而成

从您所写的内容来看,Apache似乎没有阅读/遵循。htaccess。如果AllowOverride 该目录的设置未处于活动状态。(See this thread on StackOverflow for more information.)

<Directory /var/www/>
    Options  FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
设置此(AllowOverride None -&燃气轮机;AllowOverride All) 重启Apache应该可以解决这个问题。