discuzx2.5放在目录中的nginx rewrite规则

如果论坛放在/club目录时,nginx中对应server{}的discuz rewrite可使用如下规则实现伪静态。

 

location /club/ {
    index index.php;
    try_files $uri $uri/ @discuz;
}

location @discuz {
    rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
    rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
    rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
    rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
    rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
    rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
    rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
    rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
    rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
    if (!-e $request_filename) {
    return 404;
    }
}

nginx使用phpmyadmin及配置

要求:在nginx环境下,打开服务器的http://ip/phpmyadmin或http://域名/phpmyadmin都能够使用phpmyadmin,则只需在对应网站的server{}中添加如下配置即可。

#------ nginx.conf phpmyadmin ------#
        location /phpmyadmin {
                alias /usr/share/phpMyAdmin;
                index index.php;
        }
        location ~ ^/phpmyadmin/.+\.php$ {
                if ($fastcgi_script_name ~ /phpadmin/(.+\.php)$) {
                        set $valid_fastcgi_script_name $1;
                }
                include        fastcgi_params;
                fastcgi_index  index.php;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_param  SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
        }

#------ nginx.conf phpmyadmin end ------#