1.先执行加载rewrite模块
sudo a2enmod rewrite
2.打开Apache2.conf
sudo vi /etc/apache2/apache2.conf
把
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
改成
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
3、重点在这里!wordpress提示在.htaccess加入它提示的规则语句,这里的.htaccess不是wordpress文件中存在的那个,而需要在Apache网站根目录下创建,并写入规则语句。
4、重启apache2
sudo service apache2 restart