最新消息: 新版网站上线了!!!

yii nginx下配置伪静态的方法

nginx安全配置如下
server {
        server_name kuitao8.com;
 
        root /usr/share/nginx/html;
        index index.html index.php;
 
        #Yii Specific location configurations.
 
        #SEF URLs for sampleapp. 
        location /sampleapp {
         rewrite ^/sampleapp/(.*)$ /sampleapp/index.php?r=$1;
        }
 
        location ~ /(protected|framework|nbproject) {
            deny all;
            access_log off;
            log_not_found off;
        }
 
        location ~ /themes/\w+/views {
            deny all;
            access_log off;
            log_not_found off;
        }
 
        location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
                try_files $uri =404;
        }
 
        #End Yii Specific specific location configurations.
 
        location ~ \.php$ {
                root            /usr/share/nginx/html;
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include         fastcgi_params;
        }
 
 
}

Yii confugration(main.php)

                'urlManager'=>array(
                        'urlFormat'=>'path',
                        'showScriptName'=>false,
                        'rules'=>array(
                                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                        ),
                )

转载请注明:谷谷点程序 » yii nginx下配置伪静态的方法