尽管进行了所有必要的设置,WordPress固定链接仍无法工作

时间:2020-09-21 作者:fischgeek

我为这个看似重复的问题帖子道歉,但我似乎找不到遇到我的具体问题并解决了它的人。This post 很接近,但我做了他们做的一切。

我现在的处境是:

将wp站点迁移到运行ubuntu 18的AWS服务器上的重写模式已启用/home/ubuntu/sites/my-wp-site"Directory" 具有的节"AllowOverride All" 设置站点的。htaccess文件具有由UI中的permalinks设置设置的重写规则,apache2配置还具有"AllowOverride All" 设置为"Directory" 指向的部分/home/ubuntu/sites

。将永久链接设置为日期和时间后的htaccess内容(否则为空)

 BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/jpg "access plus 1 year"
        ExpiresByType image/jpeg "access plus 1 year"
        ExpiresByType image/gif "access plus 1 year"
        ExpiresByType image/png "access plus 1 year"
        ExpiresByType text/css "access plus 1 month"
        ExpiresByType application/pdf "access plus 1 month"
        ExpiresByType text/javascript "access plus 1 month"
        ExpiresByType text/html "access plus 5 minutes"
        ExpiresByType image/x-icon "access plus 1 year"
        ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
Options -Indexes

                                <IfModule mod_rewrite.c>
                                        RewriteEngine On
                                        RewriteBase /
                                        RewriteRule ^/wp-content/endurance-page-cache/ - [L]
                                        RewriteCond %{REQUEST_METHOD} !POST
                                        RewriteCond %{QUERY_STRING} !.*=.*
                                        RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\\-postpass|wordpress_logg$
                                        RewriteCond %{DOCUMENT_ROOT}/wp-content/endurance-page-cache/$1/_index.html -f
                                        RewriteRule ^(.*)$ /wp-content/endurance-page-cache/$1/_index.html [L]
                                </IfModule>
<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
亚太地区2。形态

...
<Directory /home/ubuntu/sites/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
...

现场vhost

...
DocumentRoot /home/ubuntu/sites/my-wp-site.com
...
<Directory /home/ubuntu/sites/my-wp-site.com>
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>
...

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

由于域/站点具有ssl,因此ssl的vhosts文件是单独的,也需要更新。不仅仅是普通的端口80入口。

vhost(:80)

我的wp站点。com。形态

<VirtualHost *:80>
...
DocumentRoot /home/ubuntu/sites/my-wp-site.com
...
<Directory /home/ubuntu/sites/my-wp-site.com>
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>
...
</VirtualHost>
vhost(:443)我的wp站点。com le ssl。形态

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ...
    ServerName my-wp-site.com
    ServerAlias my-wp-site.com
    DocumentRoot /home/ubuntu/sites/my-wp-site.com
    <Directory /home/ubuntu/sites/my-wp-site.com>
        Options None FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ...
</VirtualHost>
</IfModule>