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);
    }

 

posted @ 2018-05-19 00:41  maoriaty  阅读(146)  评论(0编辑  收藏  举报