21,886
社区成员
发帖
与我相关
我的任务
分享
AppController extends Controller {
public function beforeFilter() {
parent::beforeFilter();
$current_ctl = strtolower($this->name);
if($current_ctl === 'pages'){
//在这里echo的打断点的话,sae里面也可以正常显示
$this->redirect(array('controller' => 'test', 'action' => 'index'));
}
}
}
class TestController extends AppController {
var $name = 'test';
var $uses = Array('');
public function index() {
/*这里echo打断点已经没用了,初步怀疑是大小写问题,但是我实验过了很多中,比如文件名带下划线,不带下划线,首字母大写,小写。name名改成Test,以及声明name用public的都无效*/
$this->set('CN', '中文测试');
}
}
<h2><?php echo $CN; ?></h2>
handle:
- rewrite:if (!is_file() && !is_dir() && path ~ "^app/webroot/(.*)") goto "app/webroot/index.php?url=$1&%{QUERY_STRING}"
- rewrite:if (!is_file() && !is_dir() && path ~ "(.*)") goto "app/webroot/$1?%{QUERY_STRING}"
就可以实现跳转了。