Yii nginx 环境下的路由配置

Nginx配置

在nginx.conf的server {段添加类似如下代码:
Nginx.conf代码:

location / {
    if (!-e $request_filename){#必须有空格
        rewrite ^/(.*) /index.php last;
    }
}

在Yii的protected/conf/main.php去掉如下的注释

Php代码:

'urlManager'=>array(
	'urlFormat'=>'path',
	'rules'=>array(
		'/'=>'/view',
		'//'=>'/',
		'/'=>'/',
	),
),
comments powered by Disqus