此篇主要解决在LNMP环境下应用各种框架带来的规则重写问题。
ThinkPHP
TP框架有3种链接格式,参考:http://www.thinkphp.cn/code/937.html
location / {
index index.php index.html index.htm;
#兼容3种格式的重写规则,注意不要少了}
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
#针对TP框架隐藏掉index.php,且带.html后缀的重写规则
# if (!-e $request_filename) {
# rewrite ^(.*)$ /index.php?s=$1 last;
# break;
# }
Typecho
# 在server下加入以下重写规则
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-e $request_filename){
rewrite (.*) /index.php;
}
评论区