以www.ff.com为例,访问后台的路径则为www.ff.com/admin
server {
listen 80;
server_name www.ff.com;
set $root /home/wwwroot/ff;
root $root;
index index.php;
access_log /home/wwwroot/ff/logs/access.log;
error_log /home/wwwroot/ff/logs/error.log;
location / {
root /home/wwwroot/ff/frontend/web;
try_files $uri /frontend/web/index.php?$args;
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
access_log off;
expires 360d;
try_files $uri =404;
}
}
location /admin {
alias /home/wwwroot/ff/backend/web;
rewrite ^(/admin)/$ $1 permanent;
try_files $uri /backend/web/index.php?$args;
}
location ~ ^/admin/(.+\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar))$ {
access_log off;
expires 360d;
rewrite ^/admin/(.+)$ /backend/web/$1 break;
rewrite ^/admin/(.+)/(.+)$ /backend/web/$1/$2 break;
try_files $uri =404;
}
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
try_files $uri =404;
}
location ~ /\.ht {
deny all;
}
}
网友评论