查看: 110045|回复: 334

伪静态规则(nginx)

[复制链接]
  • TA的每日心情

    2020-4-12 22:16
  • 签到天数: 71 天

    [LV.6]常住居民II

    发表于 2015-6-7 20:57:00 | 显示全部楼层 |阅读模式
    本帖最后由 以谁为师 于 2015-6-7 21:02 编辑

    WordPress伪静态
    [AppleScript] 纯文本查看 复制代码
    if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
    rewrite (.*) /index.php;
    }


    PHPCMS伪静态
    [AppleScript] 纯文本查看 复制代码
    rewrite ^/caipu-([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;
    


    DEDECMS伪静态
    [AppleScript] 纯文本查看 复制代码
    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;
    

    Discuz7伪静态
    [AppleScript] 纯文本查看 复制代码
    rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
    rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
    rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last;
    rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
    rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
    

    DiscuzX伪静态
    [AppleScript] 纯文本查看 复制代码
    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 ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
    if (!-e $request_filename) {
    return 404;
    }


    ECSHOP伪静态
    [AppleScript] 纯文本查看 复制代码
    if (!-e $request_filename)
    {
    rewrite "^/index\.html" /index.php last;
    rewrite "^/category$" /index.php last;
    rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last;
    rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last;
    rewrite "^/feed\.xml$" /feed.php last;
    rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;
    rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last;
    rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;
    rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last;
    rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last;
    rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last;
    rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last;
    rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;
    rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last;
    rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last;
    rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last;
    rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;
    rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last;
    rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last;
    rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last;
    rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last;
    rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last;
    rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last;
    rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last;
    rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last;
    rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last;
    rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;
    rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last;
    rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last;
    }


    PHPWind伪静态
    [AppleScript] 纯文本查看 复制代码
    rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
    rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
    SaBlog2.0伪静态[mw_shl_code=applescript,true]
    # 只带月份的归档
    rewrite "^/date/([0-9]{6})/?([0-9]+)?/?$" /index.php?action=article&setdate=$1&page=$2 last;
    # 无分类翻页
    rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last;
    # 分类
    rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last;
    rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last;
    # 归档、高级搜索
    rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last;
    # 全部评论、标签列表、引用列表 带分页
    rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last;
    # tags
    rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last;
    # 文章
    rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last;
    # RSS rewrite ^/rss/([0-9]+)?/?$ /rss.php?cid=$1 last;
    rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last;
    # 用户 rewrite ^/uid/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&uid=$1&page=$2 last;
    rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last;
    # 地图文件
    rewrite sitemap.xml sitemap.php last;
    # 自定义链接
    rewrite ^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last; 
    

    SHOPEX伪静态
    [AppleScript] 纯文本查看 复制代码
    if (!-e $request_filename) {
    rewrite ^/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ /index.php?$1 last;
    }


    Typecho伪静态
    [AppleScript] 纯文本查看 复制代码
    if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
    rewrite (.*) /index.php;
    }
    
    Wecenter伪静态[mw_shl_code=applescript,true]
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }


    ThinkPHP
    [AppleScript] 纯文本查看 复制代码
    server {
        listen       80;
        server_name  [url]www.a.com[/url];
        root /Users/gongwen/myweb/a; # 该项要修改为你准备存放相关网页的路径
        location / {
            index  index.php index.html index.htm;
             #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
             if (!-e $request_filename)
             {
                #地址作为将参数rewrite到index.php上。
                rewrite ^/(.*)$ /index.php/$1;
                #若是子目录则使用下面这句,将subdir改成目录名称即可。
                #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
             }
        }
        #proxy the php scripts to php-fpm
        location ~ \.php {
            include /usr/local/etc/nginx/fastcgi.conf;
                    ##pathinfo支持start
                    #定义变量 $path_info ,用于存放pathinfo信息
                    set $path_info "";
                    #定义变量 $real_script_name,用于存放真实地址
                    set $real_script_name $fastcgi_script_name;
                    #如果地址与引号内的正则表达式匹配
                    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                            #将文件地址赋值给变量 $real_script_name
                            set $real_script_name $1;
                            #将文件地址后的参数赋值给变量 $path_info
                            set $path_info $2;
                    }
                    #配置fastcgi的一些参数
                    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                    fastcgi_param SCRIPT_NAME $real_script_name;
                    fastcgi_param PATH_INFO $path_info;
                    ###pathinfo支持end
            fastcgi_intercept_errors on;
            fastcgi_pass   127.0.0.1:9000;
        }
     }
    回复

    使用道具 举报

    该用户从未签到

    发表于 2015-6-26 20:06:45 | 显示全部楼层
    感谢楼主的分享~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2015-6-27 05:52:53 | 显示全部楼层
    支持中国红客联盟(ihonker.org)
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2019-2-12 22:05
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 2015-6-27 16:24:06 | 显示全部楼层
    加油!干倒冰儿和酒仙!
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2015-6-27 16:40:43 | 显示全部楼层
    还是不错的哦,顶了
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2015-6-28 09:33:16 | 显示全部楼层
    还是不错的哦,顶了
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2022-10-21 10:32
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2015-6-28 18:56:53 | 显示全部楼层
    支持,看起来不错呢!
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2015-6-28 22:00:35 | 显示全部楼层
    感谢楼主的分享~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2015-6-28 22:14:02 | 显示全部楼层
    学习学习技术,加油!
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2015-6-29 19:37:30 | 显示全部楼层
    支持,看起来不错呢!
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    指导单位

    江苏省公安厅

    江苏省通信管理局

    浙江省台州刑侦支队

    DEFCON GROUP 86025

    旗下站点

    邮箱系统

    应急响应中心

    红盟安全

    联系我们

    官方QQ群:112851260

    官方邮箱:security#ihonker.org(#改成@)

    官方核心成员

    Archiver|手机版|小黑屋| ( 苏ICP备2021031567号 )

    GMT+8, 2024-11-22 01:23 , Processed in 0.030425 second(s), 12 queries , Gzip On, MemCache On.

    Powered by ihonker.com

    Copyright © 2015-现在.

  • 返回顶部