CodeIgniter URL
来源:互联网 发布:拼多多数据抓取 编辑:程序博客网 时间:2024/05/19 04:06
CI的URL默认风格是这样的example.com/index.php/news/article/my_article
index.php是所有请求的入口,index.php会根据url后面部分路由请求到不同的处理器上
为了让所有的请求都发送到index.php,你需要修改apache的rewrite规则(URL 重写规则)
如果你有apache配置文件的修改权限,直接修改httpd.conf配置文件的virtualhost的rewrite规则,这样是服务器处理效率最高的,如果没有权限,你可以修改根目录.htaccess文件。
增加如下rewrite规则
Options Includes FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
rewrite详细说明参考:
http://www.zzbaike.com/wiki/Apache/RewriteRule#RewriteRule_.E7.9A.84.E8.A7.84.E5.88.99.E4.BB.A5.E5.8F.8A.E5.8F.82.E6.95.B0.E8.AF.B4.E6.98.8E
添加上面的规则之后,所有请求都会被转发到index.php,同时,你的url中不必出现index.php了,你可以这样写url:example.com/news/article/my_article
其中news是类名、article是函数名
通过修改config/config.php这个配置文件中$config['url_suffix']这个参数,可以给url添加指定的后缀,如.html,有利于SEO。修改后的url如下:example.com/news/article/my_article.html看起来更像一个静态url。
如果你不想采用如上风格的URL,可以使用如下风格的url
example.com?c=news&m=article¶=my_aiticle
c表示controller、m表示method
需要修改 application/config/config.php 如下参数:
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
友情链接:网购优惠网
- CodeIgniter URL
- CodeIgniter URL
- CodeIgniter lighttpd URL重写
- codeigniter启用URL模式
- codeigniter如何支持中文URL?
- CodeIgniter 的url中去掉index.php
- Codeigniter(CI) 去掉 URL 中的 index.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
- 去掉CodeIgniter URL中的index.php
- 去掉CodeIgniter URL中的index.php
- 在CodeIgniter删除URL中的index.php
- [PHP]去掉CodeIgniter URL中的index.php
- codeigniter 移除 URL 中的 index.php
- 路由器设置VPN应用[IPSec篇]
- java之httpclient点点补充-登录问题
- CodeIgniter是什么?
- 基于FFMPEG 的跨平台视频编解码研究
- JQuery 的logger 插件
- CodeIgniter URL
- Prism 简介
- CodeIgniter控制器
- 我 的 OLAP 之 数据 模型 映射(转换)二
- 在Sencha Touch 2中使用表单
- .net中RSA的加密与解密
- ASCII表
- CodeIgniter视图
- jsp中导出excel方法 displaytag