我需要使用.htaccess
多站点的文件?我已经安装了基本wordpress站点,并使用apache2 VirtualHost将其配置为:
<VirtualHost *:80>
...
RewriteEngine On
Options FollowSymLinks
# THIS REDIRECTS TO HTTPS
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
DocumentRoot /var/www/example/
<Directory /var/www/example/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
...
DocumentRoot /var/www/example/
<Directory /var/www/example/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
但是,当我按照步骤启用多站点时,wordpress会提示我将这些选项粘贴到.htaccess
文件:RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\\.php)$ $1 [L]
RewriteRule . index.php [L]
但我没有.htaccess
文件然而,如果我成功了,并且配置了apache,重写规则就不起作用了,例如:。example.com/wp-admin
未重写为wp-admin/
带有尾部斜杠,但变成了丑陋的长链接:https://example.com/wp-login.php?redirect_to=https%3A%2F%2Fexample.com%2Fwp-admin%2F&reauth=1
. 这可能是因为SSL重写规则吗?我的问题是:我需要.htaccess
? 我如何使其重写规则起作用?