lnmp nginx wordpress 子目录 伪静态规则

单一目录rewrite伪静态规则:(根据WP所在目录改写/blog部分)

location / {
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 (.*) /blog/index.php;
}
}


多个wordpress程序,多个子目录:(根据WP所在目录改写/blog和/paste部分)

location /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 (.*) /blog/index.php;
}
}
location /paste/ {
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 (.*) /paste/index.php;
}
}

改写完wordpress.conf,执行下列语句重新启动Nginx的web环境:

/usr/local/nginx/sbin/nginx -s  reload

发表评论

电子邮件地址不会被公开。 必填项已用*标注