环境为
windows10
php 5.6
apache2.4
- 在http.conf中打开LoadModule rewrite_module modules/mod_rewrite.so
将前面的#去掉
<Directory "D:/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn‘t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# 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 All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
AllowOverride None将其改为AllowOverride All
2.进入到CI根目录,新建.htaccess文件,输入
RewriteEngine on
RewriteCond $1 !^(index\.php|style|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
当然如果你的目录不是根目录,则要注意,比如我的URL为
,则最后一行 要改为
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
3. 将CI中配置文件(application/config/config.php)中
$config[‘index_page‘] = "index.php";
改成
$config[‘index_page‘] = "";
4.重启apache