Yii 2.0 网页程序 Nginx 配置实例
{ Nginx 规则 }
server {
listen 80;
server_name yiilib.com *.yiilib.com;
access_log /var/log/nginx/yiilib.com.access.log main;
root path_to_Yiilib.com/frontend/web;
location / {
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
index index.php;
}
location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
root /var/www/html/yiilib.com/frontend/web;
}
location ~\.php$ {
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
fastcgi_split_path_info ^(.+\.php)(/._)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = ~/robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
{ Yii 2.0 urlManager }
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
//rules go here
'<controller>' => '<controller>', // default to site/index
'<controller>/<action>' => '<controller>/<action>', // default to site/index
]
]
留言