如果使用LNMP环境搭建需要在配置文件中加入
server {
listen 80;
server_name xxx;
location / {
root html/blog;
#######加入以下代码#######
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent; //这行是为了防止打开后台、插件页等打不开的。
#######################
index index.html index.htm index.php;
}
#php解析
location ~ .*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
access_log logs/access_blog.log main;
}