版本:CodeIgniter_2.0.1
希望CI 应用的URL不包含index.php
例如: http://www.example.com/index.php/product/712
希望变成这样http://www.example.com/product/712
这样url更漂亮,也许这样seo更友好,通过urlrewrite就可以实现
只需用下面3个步骤就可以搞定:
1.建立.htaccess写入重写规则如下
[code]
<IfModule mod_rewrite.c>
??? RewriteEngine On
??? RewriteBase /
??? #Removes access to the system folder by users.
??? #Additionally this will allow you to create a System.php controller,
??? #previously this would not have been possible.
??? #'system' can be replaced if you have renamed your system folder.
??? RewriteCond %{REQUEST_URI} ^system.*
??? RewriteRule ^(.*)$ /index.php?/$1 [L]
???
??? #When your application folder isn't in the system folder
??? #This snippet prevents user access to the application folder
??? #Submitted by: Fabdrol
??? #Rename 'application' to your applications folder name.
??? RewriteCond %{REQUEST_URI} ^application.*
??? RewriteRule ^(.*)$ /index.php?/$1 [L]
??? #Checks to see if the user is attempting to access a valid file,
??? #such as an image or css document, if this isn't true it sends the
??? #request to index.php
??? RewriteCond %{REQUEST_FILENAME} !-f
??? RewriteCond %{REQUEST_FILENAME} !-d
??? RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
??? # If we don't have mod_rewrite installed, all 404's
??? # can be sent to index.php, and everything works as normal.
??? # Submitted by: ElliotHaughin
??? ErrorDocument 404 /index.php
</IfModule>?
[/code]
2.设置$config['index_page']为空置
打开文件system/application/config/config.php把代码
[php]$config['index_page'] = "index.php";[/php]
改为
[php]$config['index_page'] = '';[/php]
3.确保apache支持url重写,重启apache
详细解决方案
除了codeigniter地址中的index.php
热度:42 发布时间:2016-04-28 22:50:34.0
相关解决方案
- index.jsp经过模拟action接口 转发 到login.jsp页面后,页面背景无法显示
- Parameter index out of range (五 > number of parameters, which is 4)
- 求高手看一看!index.jsp可以进,在往上点就出现有关问题了
- tomcat启动出现Caused by: java.lang.StringIndexOutOfBoundsException: String index out解决方法
- JSP有关问题 index.jsp使用meta 页面都跳转不过去
- 小白请问: 关于 index.jsp 中 isValid() == false的异常。 就剩20分了.对不住各位了><
- java.lang.StringIndexOutOfBoundsException: String index out of range: 12
- 为什么数组上标(index)只能为int不能为long
- ora-08102:index key not found,obj#57848,file 六, block 6324(2)
- 索引超出范围。必须为非负值并小于集合大小。参数名: index
- menu控件 异常 索引必须位于该列表的界限内。 参数名: index
- Index”并不包孕“productType1”的定义
- 异常:索引超出范围。必须为非负值并小于集合大小。参数名: index
- 目录超出范围。必须为非负值并小于集合大小。参数名: index(三层)
- http://localhost:49538/TPInfoPlat/index.html没法显示网页,去掉数字就可以显示了
- 急纠结z-index
- datagridview,想实现编辑数据的功能 指定的参数已超出有效值的范围。 参数名: index;”解决办法
- jquery index()的有关问题帮小弟我看下这行代码错在哪
- 指定的参数已超出有效值的范围。 参数名: index,该怎么解决
- ASP.net报错提示:指定的参数已超出有效值的范围。参数名: index,添加OnRowDataBound="gvEditMember_RowD这个事件就报错,该如何处理
- <a href='MyPhoto.aspx?DelID=<%# Eval("album_id") %>&index=hddnPageIndex.value' />解决方法
- http://localhost:2263/biaoyuan/(S(vdgswrvs3qwzo1feus4cm355))/Index.aspx解决思路
- <div id="Layer25" style="position: absolute; width: 127px; height: 67px; z-index: 35
- <div id="Layer25" style="position: absolute; width:1000px; height:1000px; z-index: 35; background-color:red,该如何处理
- |M|小弟我也有搞鬼 <div style="position: absolute; width: 1000px; height: 1000px; z-index: 35; background-color:red"
- OnClick=window.open("/index.aspx")出错?解决思路
- 地址栏出现乱码 http://localhost:45019/WEB/(S(jtlpw455vp3udnbiufilzh45))/index.aspx,该如何处理
- 虚拟主机 index.htm解决办法
- http://www.fname.cn/jts/(S(5afv1k55frqf5iqamlygej55))/index.aspx 為什麼地址欄上會多出一些隨機字符呢
- int index = int.Parse(e.CommandArgument.ToString());该怎么处理