server { listen 80; server_name afreelyrics.com www.afreelyrics.com; #host跳转到主域名 if ($host != "afreelyrics.com") { rewrite ^(.*) http://afreelyrics.com$1 permanent; } access_log /var/log/nginx/afreelyrics.com/access.log; error_log /var/log/nginx/afreelyrics.com/error.log; root /srv/www_root/afreelyrics.com/web; #优先读取static目录下的静态页 if (-f "${document_root}/static${uri}") { rewrite ^/(.*)$ /static/$uri break; } #lyrics detail,must befor artist detail rewrite ^/([^/]+)/([^/]+)\.html$ /index.php/lyrics/lyrics/$1/$2 break; #artist detail rewrite ^/([^/]+)\.html$ /index.php/artist/artist/$1 break; #search rewrite ^/s/([^/]*)/?$ /index.php/search/index/$1 break; rewrite ^/s-lyrics/([^/]+)(/|/(\d+)\.html?)?$ /index.php/search/lyrics/$1/$3 break; rewrite ^/s-artist/([^/]+)(/|/(\d+)\.html?)?$ /index.php/search/artist/$1/$3 break; #php if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 break; } location ~* \.(js|css|gif|jpeg|jpg|png|ico|bmp)$ { expires 3d; break; } include /etc/nginx/php.conf; } server { listen 80; server_name *.afreelyrics.com; return 404; } #php.conf location ~* \.php($|/) { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SERVER_NAME $server_name; fastcgi_param PATH_INFO $fastcgi_script_name; } (责任编辑:IT) |