通过 SSH 在我的 Ubuntu 服务器上的 apache 虚拟主机配置中添加“AllowOverride All”(如其他作者之前所暗示的)对我来说是成功的:
sudo vi /etc/apache2/sites-available/my-website-name.com.conf
还有(如果你使用letsencrypt):
sudo vi /etc/apache2/sites-available/my-website-name.com-le-ssl.conf
这些文件应如下所示:
<VirtualHost *:80>
# or <VirtualHost *:443> for the SSL configuration
# [...]
DocumentRoot /var/www/my-website-name.com/public_html
<Directory "/var/www/my-website-name.com/public_html">
# this allows .htaccess files (e.g. generated by Wordpress)
# to overwrite the apache configuration on a directory basis:
AllowOverride All
</Directory>
# [...]
</VirtualHost>
不要忘记禁用并重新启用站点并重新加载 apache 以应用新配置:
sudo a2dissite my-website-name.com.conf
sudo a2dissite my-website-name.com-le-ssl.conf
sudo a2ensite my-website-name.com.conf
sudo a2ensite my-website-name.com-le-ssl.conf
sudo service apache2 reload