CI框架学习之–隐藏入口文件-index.php

一般CI框架第一次使用时:

原地址为:
http://127.0.0.1/CI/index.php/hello/index
隐藏入口文件后只需要把地址写成即可:
http://127.0.0.1/CI/hello/index

第一步、需要开启Apache的 rewrite 功能 Apache\conf\httpd.conf 修改,然后重启Apache.修改内容如下:
————————————————————————————
修改前:
#LoadModule rewrite_module modules/mod_rewrite.so


# 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

修改成:
# 搜索 mod_rewrite 与 .htaccess 关键字来进行查询修改项
LoadModule rewrite_module modules/mod_rewrite.so

<Directory “c:/www”>
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
Order allow,deny
Allow from all
</Directory>
————————————————————————————

第二步:在入口文件同级目录(system/application同级目录)中,放入一个.htaccess 内容如下:

————————————————————————————

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
————————————————————————————

第三步:配置CI索引页 \application\config\config.php

原: $config[‘index_page’] = ‘index.php’;
修改成:$config[‘index_page’] = ”;

[乐于学习,勤于思考] - wrox.org & baidu.com.ru - 本站原创,转载请注明出处!

Add a Comment

Your email address will not be published. Required fields are marked *