1.激活mod_rewrite
a2enmod rewrite
systemctl restart apache2
2.修改/etc/apache2/sites-available/000-default.conf
vim /etc/apache2/sites-available/000-default.conf
在<VirtualHost *:80>下面插入一下内容
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
保存之后,重启apache2
systemctl restart apache2
3.在/var/www/html/wordpress这个目录下面创建一个文件.htaccess(此文件可能已经存在,但是默认是隐藏的),修改内容为
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
保存之后,再在浏览器里访问wordpress里面的链接试试,如下图:
作者:jessica1123
链接:https://www.jianshu.com/p/d829b7bd3ef7
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。