去掉CodeIgniter(CI)默认url中的index.php
来源:互联网 发布:艾克里里用什么软件 编辑:程序博客网 时间:2024/04/30 10:07
1.打开apache的配置文件,conf/httpd.conf :
1
LoadModule rewrite_module modules/mod_rewrite.so
把该行前的#去掉。
搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为:
1
AllowOverride All
2.在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):
1
2
3
4
5
RewriteEngine
on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
如果文件不是在www的根目录下,例如我的是:
1
http:
//localhost/ci_demo_1/index.php/
第三行需要改写为
1
RewriteRule ^(.*)$ /CI/index.php/$1 [L]
另外,我的index.php的同级目录下还有assets文件夹,这些需要过滤除去,第二行需要改写为:
1
RewriteCond $1 !^(index\.php|images|assets|robots\.txt
3.将CI中配置文件(application/config/config.php)中
1
$config[
'index_page'
] =
"index.php"
;
改成
1
$config[
'index_page'
] =
""
;
重启apache,完成。
=========================================================================================================================
php 框架ci去index.php的方法
网上有很多方法都要引入.htaccess文件,如果是在测试环境下,动态和静态的文件放到一块,可能测试会有一定的问题(由于全部定向到index.php),静态网页访问不了。
这里提供一种方法,只需要修改http.conf文件,
步骤:
1 :在配置虚拟目录下加入
1
2
3
4
5
6
7
8
9
10
11
<Directory />
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow
from
all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine
on
RewriteRule ^/script/(.*) /script/$1 [L]
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
2 将下面这行前面的;去掉
1
LoadModule rewrite_module modules/mod_rewrite.so
3 重启apache就可以了,无需加入.htaccess文件
0 0
- CodeIgniter(CI)去掉默认url中的index.php
- 去掉CodeIgniter(CI)默认url中的index.php
- 去掉CodeIgniter(CI)默认url中的index.php
- 去掉CodeIgniter(CI)默认url中的index.php
- Codeigniter(CI) 去掉 URL 中的 index.php
- PHP CI(CodeIgniter) 如何去掉url中的index.php
- 去掉CodeIgniter(CI)默认url中的index.php的步骤:
- 去掉CI默认url中的index.php
- 去掉CI默认url中的index.php
- 如何去掉CI (codeigniter)url中的index.php
- 去掉php框架CI默认url中的index.php
- 去掉php框架CI默认url中的index.php
- [PHP]去掉CodeIgniter URL中的index.php
- 去掉CodeIgniter URL中的index.php
- 去掉CodeIgniter URL中的index.php
- CodeIgniter框架去掉url中的index.php
- 去掉CodeIgniter URL中的index.php
- 去掉CodeIgniter URL中的index.php
- 微信公众号项目笔记 二
- 面试感悟----一名3年工作经验的程序员应该具备的技能
- oracle之存储过程5-查询结果保存到变量中去
- 如何理解c++this指针
- 彻底理解 JS 中 this 的指向
- 去掉CodeIgniter(CI)默认url中的index.php
- AndroidStudio 编译C/C++文件生成SO文件
- servlet3异步处理请求
- Hibernate load()与get()区别
- Java中String,StringBuffer和StringBuiled的区别
- 菜鸟的Java之路:第一集
- 深度学习数据集——MNIST
- 2017年十大GitHub的编程语言:JavaScript是不是第一
- 排序算法总结