1.开启rewrite模块
vim httpd.conf
#[plain] view plain copy
LoadModule rewrite_module modules/mod_rewrite.so
2.开启AllowOverride
[plain] view plain copy
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
修改 AllowOverride None 为 AllowOverride All 关于AllowOverride 说明:
AllowOverride参数就是指明Apache服务器是否去找.htaccess文件作为配置文件,如果设置为none,那么服务器将忽略.htacess文件,如果设置为All,那么所有在.htaccess文件里有的指令都将被重写。对于AllowOverride,还可以对它指定如下一些能被重写的指令类型.
通常利用Apache的rewrite模块对 URL 进行重写的时候, rewrite规则会写在 .htaccess 文件里。但要使 apache 能够正常的读取.htaccess 文件的内容,就必须对.htaccess 所在目录进行配置。从安全性考虑,根目录的AllowOverride属性一般都配置成不允许任何Override ,即
代码如下: