jialiguo 发表于 2018-11-18 12:55:47

centos 开启apache伪静态

  1.开启rewrite模块
vim httpd.conf
# view plain copy
LoadModule rewrite_module modules/mod_rewrite.so  

  2.开启AllowOverride
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 ,即
代码如下:

AllowOverride None

在 AllowOverride 设置为 None 时, .htaccess 文件将被完全忽略。当此指令设置为 All 时,所有具有 ".htaccess" 作用域的指令都允许出现在 .htaccess 文件中。
而对于 URL rewrite 来说,至少需要把目录设置为
代码如下:
< Directory /myblogroot/>
AllowOverride FileInfo
< /Directory>  

  3.允许apache支持.htaccess
view plain copy
Options FollowSymLinks
AllowOverride None
修改为
view plain copy
Options FollowSymLinks
AllowOverride All  

  4.重启进程
systemctl restart httpd.service  




页: [1]
查看完整版本: centos 开启apache伪静态