去掉CodeIgniter URL中的index.php
CI默认的rewrite url中是类似这样的,例如你的CI根目录是在/CodeIgniter/下,你的下面的二级url就类似这样http://localhost /CodeIgniter/index.php/welcome。不太好看,怎么把其中的index.php取掉呢?
1. 打开apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉。
搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为AllowOverride All。
2. 在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):
1 RewriteEngine on
2 RewriteCond $1 !^(index\.php|images|robots\.txt)
3 RewriteRule ^(.*)$ /index.php/$1 [L]
如果文件不是在www的根目录下,例如我的是:http://www.nowamagic.net/CodeIgniter/,第三行需要改写为RewriteRule ^(.*)$ /CodeIgniter/index.php/$1 [L]。
另外,我的index.php的同级目录下还有js文件夹和css文件夹,这些需要过滤除去,第二行需要改写为:RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
3.将CI中配置文件(system/application/config/config.php)中$config['index_page'] = "index.php";将$config['index_page'] = ""; 。
01 /*
02 |--------------------------------------------------------------------------
03 | Index File
04 |--------------------------------------------------------------------------
05 |
06 | Typically this will be your index.php file, unless you've renamed it to
07 | something else. If you are using mod_rewrite to remove the page set this
08 | variable so that it is blank.
09 |
10 */
11 $config['index_page'] = '';
ok,完成。还要记得重启apache。
就这么简单,好好体验CI吧~
去掉CodeIgniter URL中的index.php的更多相关文章
- ThinkPHP路由去掉隐藏URL中的index.php
官方默认的.htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On ...
- CI在nginx环境下去掉url中的index.php
在nginx环境下CI框架默认URL规则访问不了,出现500错误,如: http://blog.php230.com/index.php/keywords 今天在服务器配置CI框架环境时,去除URL中 ...
- ThinkPHP 隐藏URL中的 index.php
去掉 URL 中的 index.php 通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通过URL重写的方式可以达到这种效果,通常需要服务 ...
- Elasticsearch——禁止Body中的index覆盖Url中的index参数
本篇继续一下Elasticsearch日常使用的技巧翻译. 在Elasticsearch有很多的api支持在body中指定_index等信息,比如mget或者msearch以及bulk. 默认的情况下 ...
- [tp3.2.1]开启URL(重写模式),省略URL中的index.php
重写模式(省略url中的index.php) 在apache配置文件httpd.conf中,查找 1.mod_rewrite.so, 启动此模块 2.AllowOverride , 值= All 3. ...
- [中级] 有效删除URL中的index.php
如果你刚接触CI不久又或者刚刚研读CI的使用手册的话,关于如何有效删除URL中index.php以使URL看起来更友好美观的问题,可能是你面对的第一个较为复杂的问题!本贴不是原创,而是一个各种意见的综 ...
- 去掉php框架CI默认url中的index.php
CI默认的rewrite url中是类似这样的 例如你的CI根目录是在/CodeIgniter/下,你的下面的二级url就类似这样 http://localhost/CodeIgniter/index ...
- 在nginx下去掉ci框架url中的index.php
ci框架默认的url规则中带有应用的入口文件,例如: example.com/index.php/news/article/my_article 在以上URL中带有入口文件index.PHP,这样的U ...
- Thinkphp中取消url中的index.php 和 Home 默认模块
将配置文件中改: <?phpreturn array( //'配置项'=>'配置值' 'URL_MODEL'=>'2', //去掉url中index.php ' ...
随机推荐
- C Primer Plus note7
这个程序是<C Primer Plus 中文版 第六版>书上198页的代码,是一个值的琢磨的程式. 有时间可以看一看: 尤其是下面这几句代码,很精妙: 用了很短的程式,得出了最大值和最小值 ...
- JBPM学习第5篇:Mysql配置
1.工作台用户Authentication配置 JBPM web工作台预安装了用户认证与授权模块,位于jbpm-console-7.1.0.Final-wildfly-10.1.0.Final.war ...
- Hibernate 注解(Annotations 一)
1. @Entity 将一个类声明为一个实体bean(即一个持久化POJO类). 2. @Table 声明了该实体bean映射指定的表(table),目录(catalog)和schema名字 3. @ ...
- BZOJ4773: 负环(倍增Floyd)
题意 题目链接 Sol 倍增Floyd,妙妙喵 一个很显然的思路(然而我想不到是用\(f[k][i][j]\)表示从\(i\)号点出发,走\(k\)步到\(j\)的最小值 但是这样复杂度是\(O(n^ ...
- Sencha Architect打开闪退问题修复
删除以下位置的cache文件夹 C:\Users\Administrator\AppData\Local\Sencha\Sencha Architect 3.2\Cache bug解决参考 https ...
- Java——实现对密码进行MD5加密
package common; /** *@author作者 E-Mail: *@version 创建时间:2015-9-24+下午01:22:44 *类说明 **/ import java.secu ...
- JavaScript中filter()方法
方法概述 用于把数组(Array)的某些元素过滤掉,然后返回剩下的元素组成的数组. 语法: var filteredArray = array.filter(callback[, thisObject ...
- 第三次Scrum编码冲刺
1.小组成员 周 斌 舒 溢 许嘉荣 唐 浩 黄欣欣 廖帅元 刘洋江 薛思汝 2.个人在小组第三次冲刺的任务及其完成情况描述. 这次小组活动中我负责测试程序的实现情况,确保程序的每个模块都能正常运行, ...
- Appium 常用方法
锁定 锁定屏幕 # python driver.lock(5) 将 app 置于后台 把当前应用放到后台去 # python driver.background_app(5) 收起键盘 收起键盘 # ...
- arcgis silverlight api 图层介绍
Layer |--TiledMapServiceLayer | |--ArcGISTiledMapServiceLayer |--DynamicLayer | |--DynamicMapService ...