server { listen 80; server_name abcdefg.cn; location / { root html/abcdefg.cn; index index.php index.html index.htm; if (!-f $request_filename){ set $rule_1 1$rule_1; } if (!-d $request_filename){ set $rule_1 2$rule_1; } if ($rule_1 = "21"){ rewrite /. /index.php last; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root html/abcdefg.cn; fastcgi_pass unix:/var/run/php-fpm.socket; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/abcdefg.cn$fastcgi_script_name; include fastcgi_params; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } }最后一个location
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; }开启后网站的css、js、图片等全部无法加载,求解。
location加上root######谢了~最后一个location加上root,刚才我加的时候少了个“;”号,嘿嘿!######第一个location已经加了root######
# 设置expires和max-age的时间 location ~* "^.+.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" { expires 30d; log_not_found off; }
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。