CI 框架隐藏index.php-ubuntu
2014-05-18 15:29
309 查看
和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单。但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步骤如下:
1.服务器环境: ubuntu12.04 64位
2.开启mod_rewrite模块:
(1)将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块.
(2)修改 /etc/apache2/sites-enabled/000-default,将其中的:AllowOverride None 修改为:AllowOverride All,如下:
重启apache2:
3.在CI的根目录下,即在system的同级目录下,新建.htaccess文件:
如果CI目录不是在www的根目录下,例如我的是:http://localhost/iter/index.php/,第四行需要改写为RewriteRule ^(.*)$ /iter/index.php/$1 [L]。
4.将CI中配置文件(system/application/config/config.php)中,将 $config['index_page'] = "index.php"; 中的index.php去掉。
大功告成,小伙伴试试看!!!
1.服务器环境: ubuntu12.04 64位
2.开启mod_rewrite模块:
(1)将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块.
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
(2)修改 /etc/apache2/sites-enabled/000-default,将其中的:AllowOverride None 修改为:AllowOverride All,如下:
DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
重启apache2:
sudo service apache2 restart
3.在CI的根目录下,即在system的同级目录下,新建.htaccess文件:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|index\.html|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
如果CI目录不是在www的根目录下,例如我的是:http://localhost/iter/index.php/,第四行需要改写为RewriteRule ^(.*)$ /iter/index.php/$1 [L]。
4.将CI中配置文件(system/application/config/config.php)中,将 $config['index_page'] = "index.php"; 中的index.php去掉。
//$config['index_page'] = "index.php"; $config['index_page'] = ""; 。
大功告成,小伙伴试试看!!!
相关文章推荐
- CI 框架怎么去掉隐藏入口文件 index.php
- 隐藏CI框架路径中的index.php方法
- CI框架 .htaccess 隐藏url在index.php解决方案
- CI框架 .htaccess 隐藏url在index.php解决方案
- CI框架学习之--隐藏入口文件-index.php
- 教你如何在CI框架中使用 .htaccess 隐藏url中index.php
- CI框架 .htaccess 隐藏url中index.php的解决
- 教你如何在CI框架中使用 .htaccess 隐藏url中index.php
- CI框架 .htaccess 隐藏url中index.php的解决(转)
- CI 框架去除URL上的index.php 来直接访问
- CI 框架(Apache环境)有效删除URL中的index.php 分类: CI框架 php 2014-01-20 13:17 266人阅读 评论(0) 收藏
- CI 框架源码 入口文件 index.php 即程序开始执行的地方
- CI框架源码阅读笔记2 一切的入口 index.php
- 在nginx下去掉ci框架url中的index.php
- ci的index.php隐藏
- CI如何隐藏index.php
- Ci下面隐藏index.php的方法
- CI 框架 入口文件 index.php 程序开始的地方
- 去掉 CI 框架中的 index.php