CodeIgniter的默认URL中有index.php,不利于用户体验,想去掉。
本地服务器为wamp环境,修改步骤:
1、新建 .htaccess文件,必须放在CI的根目录下和index.php文件在同一目录。
.htaccess 文件的内容如下:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
2、在apache配置上,注意httpd.conf文件里:
(1)去掉#,开启rewrite
LoadModule rewrite_module modules/mod_rewrite.so
(2) AllowOverride none 改为 AllowOverride all
# 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
(3)重启apache
Leave a Reply