除了codeigniter地址中的index.php
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了除了codeigniter地址中的index.php,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1713字,纯文字阅读大概需要3分钟。
内容图文
去掉codeigniter地址中的index.php版本: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 !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
?
[/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全部内容,希望文章能够帮你解决除了codeigniter地址中的index.php所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。