正如标题所说,当我在管理中更改永久链接时,我的所有页面都返回404(主页除外)。我必须包括在内index.php
作为所有不同路径的起点。如果我包括在内,所有的路径都很好index.php
.
例如:
自定义结构:/index.php/%postname%/%day%/
将在我浏览我的网站时工作。自定义结构:/%postname%/%day%/
将不工作(主页除外)。
服务器上已启用mod\\u rewrite:
$ sudo a2enmod rewrite
Module rewrite already enabled
我有一个.htaccess
文件:$cat /var/www/directory_name/.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_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
。。。并且可由web服务器写入:$ ls -al
-rwxr-xr-x 1 www-data www-data 461 Dec 3 14:11 .htaccess
我的apache配置:$ cat /etc/apache2/sites-enabled/domain.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain.com [OR]
RewriteCond %{SERVER_NAME} =www.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<Directory /var/www/domain/>
AllowOverride All
Options +FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
$cat /etc/apache2/sites-enabled/domain-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
</VirtualHost>
</IfModule>