版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35349114/article/details/80774550
- 打开apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so
-
把该行前的#去掉。搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为:
AllowOverride All
- 在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):
RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
如果不在根目录下:RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /目录/index.php/$1 [L]
-
重启apache,完成。