一、加载rewrite.so模块,默认是不加载的
1、rewrite.so模块默认路径在:/usr/lib/apache2/modules/mod_rewrite.so
2、apache2的主配置文件:apache2.conf会引用/etc/apache2/mods-enabled/下的所在的*.conf和*.load
3、/etc/apache2/mods-enabled/又软连接到/etc/apache2/mods-available/
4、进入/etc/apache2/mods-available/,新建文件rewrite.load,并加入“LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so”来加载rewrite.so模块
5、进入/etc/apache2/mods-enabled/,建立软连接,执行命令:$ ln -s ../mods-available/rewrite.load rewrite.load
二、配置apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AllowOverride All
Requireall granted
# AllowOverride None
# Require all granted
</Directory>
三、重启apache,/etc/init.d/apache2 restart