|
在控制器ccc中设置了默认方法indxe,即在访问/ccc时可以到达index方法,但是访问/ccc/(结尾多了/)就访问不到了,后面带参数的方式也方位不到了,例如 /ccc/123 (123是参数)
服务用了nginx的rewrite去掉访问链接中的index.php,rewrite代码如下:
location / {
autoindex off;
rewrite ^/press_(cn|en)\.html$ /news/newslist/$1 last;
if ( !-e $request_filename){
rewrite ^/(.+)$ /index.php/$1 last;
}
}
location ~ ^(.+\.php)(.*)$ {
root /www/web/webroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
=====================================
控制器代码:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Highlights extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index($id='0') {
$this->load->view('index');
}
}
|
|