十一个常见的Nginx伪静态规则
编辑:浏览器知识域名重指向
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
文章TAG:十一 一个 常见 nginx 十一个常见的Nginx伪静态规则加载全部内容