十一个常见的Nginx伪静态规则

im, 无色
im, 无色
im, 无色
884
文章
0
评论
2020年7月19日19:34:57 评论 488

域名重指向

if (!-e $request_filename) {
rewrite ^/(.*)$ https://cha.puerke.com/$1 permanent;
}

 

WordPress

try_files $uri $uri/ /index.php?$args;

 

Tapyeecho

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}

 

DiscuzX

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

 

PHPWIND9

if (-f $request_filename) {
    break;
}
if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {
    break;
}
if (!-e $request_filename) {
    rewrite . /index.php last;
}

 

PHPCMS

if (!-f $request_filename){
    rewrite (.*) /index.php;
}
rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;  
rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;  
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;  
rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;   
rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;   
rewrite ^/([^\.]*).html /index.php?m=member&c=index&a=$1 last;

 

帝国CMS

rewrite "^/index.html$" /index.php last;
rewrite "^/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
rewrite "^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
rewrite "^/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
rewrite "^/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
rewrite "^/tags.html$" /tags.php last;
rewrite "^/tag-([0-9]+)-([0-9]+)\.html$" /tags.php?/$1/$2/ last;
break;

 

ownCloud

try_files $uri $uri/ /index.php$uri;

 

Drupal7+

try_files $uri /index.php?$query_string;

 

phpBB

try_files $uri $uri/ /index.php;
rewrite ^/([^/]*)(forum|[a-z0-9_-]*-f)([0-9]+)(-([0-9]+))?\.html$ /$1viewforum.php?f=$3&start=$5 break;
rewrite ^/([^/]*)(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /$1viewtopic.php?f=$3&t=$5&start=$7 break;

 

DBShop

try_files $uri $uri/ /index.php?$args;

 

ThinkPHP5

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}

 

 

 

 

 

 

 

 

 

 

 

 

1

im, 无色
  • 本文由 发表于 2020年7月19日19:34:57
LNMP一键安装包 1.6 下载 PHP

LNMP一键安装包 1.6 下载

LNMP一键安装包是什么? LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RHEL/Fedora/Aliyun/Amazon、Debian/Ubuntu/Raspbian/...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: