ci的url操作

去除index.php

wamp: httpd-vhost.conf
<VirtualHost *:80> ServerName localhost ServerAlias localhost #DocumentRoot "${INSTALL_DIR}/www" #<Directory "${INSTALL_DIR}/www/"> DocumentRoot "C:\JabinDoc\php_www" <Directory "C:\JabinDoc\php_www"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost> <VirtualHost *:80> ServerName php.test.com ServerAlias php.test.com DocumentRoot "C:\JabinDoc\php_www\ci" <Directory "C:\JabinDoc\php_www\ci"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost>

ci: 根目录下.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

url配置:

#开启字符串查询,与默认方式不能同用,eg:index.php?c=products&m=view&id=345
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; //控制器所在子目录名称
url: http://php.test.com/index.php?c=welcome&m=view&d=aa&id=9 默认方式为:http://php.test.com/aa/welcome/view/8 $config['url_suffix'] = '.html'; #添加后缀,eg: http://php.test.com/welcome/view/8.html

开启enable_query_strings后参数获取:

url: http://php.test.com/index.php?c=welcome&m=view&id=9
获取:$this->input->get('id')/$_GET['id']

默认方式:

url: http://php.test.com/welcome/view/8
获取参数:
public function view($id=NULL)
    {
        echo $id;exit;
        $data['id'] = $id;
        $this->load->view('view_test',$data);
    }

 

转载于:https://www.cnblogs.com/maoriaty/p/9058599.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值