此篇主要解决在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;
            }

Joomla


文章作者: Leo
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LeoLan的小站
Web服务器 nginx PHP重写规则
喜欢就支持一下吧