静态Nginx常用Rewrite(伪静态规则)

rewrite规则  时间:2021-01-09  阅读:()

相信现在大部分用Linux VP S的朋友都在使用这个迅速传播的Nginx今天就整理一下最常见的P H P程序的Rewr it e(伪静态规则)。

WordPre s slocation/ {index index.html index.php;if(-f$re que st_filename/inde x.html){rewri te(.*)$1/inde x.html b re ak;

}if(-f$reque st_filename/ind ex.p hp){rewr ite(.*)$1/ind ex.p hp;

}if(!-f$reque st_file name){rewr ite(.*)/inde x.php;

}

}

PHPCMSlocation/ {

###以下为PHP CMS伪静态化rewrite规则rewrite^(.*)s how-([0-9]+)-([0-9]+)\.html$$1/s ho w.php?ite mid=$2&pa ge=$3;rewr i te^(.*)list-([0-9]+)-([0-9]+)\.html$$1/list.php?catid=$2&p age=$3;rewrite^(.*)s how-([0-9]+)\.html$$1/show.php?specia lid=$2;

####以下为P HP W ind伪静态化rewr ite规则rewrite^(.*)-htm-(.*)$$1.php?$2 la st;rewrite^(.*)/s imp le/([a-z0-9\_]+\.html)$ $1/s imp le/inde x.php?$2 la st;

}

EC S HO Pif(!-e$request_filename)

{rewrite "^/ind ex\.html" /inde x.p hp la st;rewrite "^/category$" /index.php last;rewrite "^/fee d-c([0-9]+)\.xml$”/feed.php?c at=$1 last;rewrite“^/fe ed-b([0-9]+)\.xml$”/feed.php?brand=$1 last;rewrite“^/feed\.xml$”/feed.php last;rewr it e“^/c ate gory-([0-9]+)-b([0-9]+)-mi n([0-9]+)-ma x([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.ht ml$”

/catego ry.p hp?id=$1&brand=$2&pric e_min=$3&p rice_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;rewr ite“^/c ate go ry-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-

]*)(.*)\.html$”/cate go ry.php?id=$1&brand=$2&p rice_min=$3&price_max=$4&filte r_at tr=$5 last;

rewr ite“^/c at e go r y-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.ht ml$”

/c ategory.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;rewr ite“^/c ate go ry-([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$”/catego ry.p hp?id=$1&brand=$2 last;rewrite“^/c ategory-([0-9]+)(.*)\.html$”/c atego ry.p hp?id=$1 la st;rewrite“^/goods-([0-9]+)(.*)\.html”/goods.php?id=$1 last;rewr it e“^/artic le_c a t-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$”

/article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;rewrite“^/artic le_cat-([0-9]+)-([0-9]+)(.*)\.html$”/artic le_cat.p hp?id=$1&p age=$2 las t;rewrite“^/artic le_cat-([0-9]+)(.*)\.html$”/artic le_cat.php?id=$1 las t;rewrite“^/artic le-([0-9]+)(.*)\.html$”/artic le.php?id=$1 last;rewr ite“^/bra nd-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-

Z]+)\.html”/brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;rewr i te“^/bra nd-([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.p hp?id=$1&cat=$2 last;rewrite“^/brand-([0-9]+)(.*)\.html”/b rand.php?i d=$1 la st;rewr ite“^/ta g-(.*)\.html”/s earch.php?keywo rds=$1 las t;rewrite“^/s natc h-([0-9]+)\.html$”/s natc h.php?id=$1 last;rewrite“^/group_b uy-([0-9]+)\.html$”/gro up_buy.p hp?act=view&id=$1 las t;rewrite“^/auction-([0-9]+)\.html$”/auction.php?act=view&id=$1 last;rewrite“^/e xc hange-id([0-9]+)(.*)\.html$”/exc hange.p hp?id=$1&a ct=view la st;rewr it e“^/e xc ha nge-([0-9]+)-min([0-9]+)-ma x([0-9]+)-([0-9]+)-(.+)-([a-zA-

Z]+)(.*)\.html$”/e xc hange.php?c at_id=$1&inte gr a l_min=$2&inte gra l_max=$3&p a ge=$4&s ort=$5&order=$6 la st;rewrite^/exc hange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$”

/exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;rewrite“^/e xc hange-([0-9]+)-([0-9]+)(.*)\.html$”

/exchange.php?cat_id=$1&page=$2 last;rewrite“^/exchange-([0-9]+)(.*)\.html$”/exchange.php?cat_id=$1 last;

}

SHOPEX:locati on/ {if(!-e$request_filename) {rewrite^/(.+\.(html|xml|j so n|htm|php|j sp|asp|shtml))$/ind ex.p hp?$1 last;

}

}

SaBlog2.0 (感谢追寻36[正冰]博客提供)

#只带月份的归档re wr it e "^/d ate/([0-9]{6})/?([0-9]+)?/?$"

/index.php?action=article&setdate=$1&page=$2 last;

#无分类翻页rewrite^/page/([0-9]+)?/?$/index.php?action=article&p age=$1 last;

#分类rewrite^/cate gory/([0-9]+)/?([0-9]+)?/?$/inde x.p hp?acti on=artic le&c id=$1&page=$2last;rew r ite^/c at e gory/([^/]+)/?([0-

9]+)?/?$/index.php?action=article&curl=$1&page=$2 last;

#归档、高级搜索rewrite^/(arc hives|search|artic le|link s)/?$/ind ex.p hp?actio n=$1 la s t;

#全部评论、标签列表、引用列表带分页rewrite^/(comme nts|tags li st|trackbacks|artic l e)/?([0-

9]+)?/?$/index.php?action=$1&page=$2 last;

#ta gs rewrite^/tag/([^/]+)/?([0-9]+)?/?$/index.php?action=article&item=$1&page=$2 last;#文章rewrite^/archive s/([0-9]+)/?([0-9]+)?/?$/index.p hp?action=show&id=$1&page=$2 last;#RSS rewrite^/rss/([0-9]+)?/?$/rss.php?cid=$1 last;rewrite^/rs s/([^/]+)/?$/rss.php?url=$1 last;

#用户rewrite^/uid/([0-9]+)/?([0-9]+)?/?$/index.p hp?ac tio n=artic le&uid=$1&page=$2la st;rewrite^/user/([^/]+)/?([0-9]+)?/?$/index.php?action=article&user=$1&page=$2 last;#地图文件rewrite sitemap.xml sitemap.php last;

#自定义链接rewr ite^(.*)/([0-9 a-zA-Z\-\_]+)/?([0-

9]+)?/?$$1/index.php?action=show&alias=$2&page=$3 last;

Discuz 7rewrite^/arc hiver/((fid|tid)-[\w\-]+\.html)$/arc hiver/inde x.php?$1 la st;rewrite^/forum-([0-9]+)-([0-9]+)\.html$/forumd isp lay.p hp?fi d=$1&pa ge=$2 la st;rewr it e^/thread-([0-9]+)-([0-9]+)-([0-

9]+)\.html$/viewthread.php?tid=$1&extra=p age\%3D$3&page=$2 la st;rewrite^/space-(username|uid)-(.+)\.html$/space.p hp?$1=$2 last;rewrite^/tag-(.+)\.html$/tag.php?name=$1 la st;

Typecholo cation/ {index index.html index.p hp;if(-f$reque st_filename/index.html){rewrite (.*)$1/index.html b reak;

}if(-f$reque st_filename/index.php){rewr ite (.*)$1/inde x.p hp;

}if(!-f$request_filename){rewr ite (.*) /ind ex.p hp;

}

}

今天暂时整理这些 以后不定期更新。

ATCLOUD-KVM架构的VPS产品$4.5,杜绝DDoS攻击

ATCLOUD.NET怎么样?ATCLOUD.NET主要提供KVM架构的VPS产品、LXC容器化产品、权威DNS智能解析、域名注册、SSL证书等海外网站建设服务。 其大部分数据中心是由OVH机房提供,其节点包括美国(俄勒冈、弗吉尼亚)、加拿大、英国、法国、德国以及新加坡。 提供超过480Gbps的DDoS高防保护,杜绝DDoS攻击骚扰,比较适合海外建站等业务。官方网站:点击访问ATCLOUD官网活...

香港云服务器 1核 1G 29元/月 快云科技

快云科技: 12.12特惠推出全场VPS 7折购 续费同价 年付仅不到五折公司介绍:快云科技是成立于2020年的新进主机商,持有IDC/ICP等证件资质齐全主营产品有:香港弹性云服务器,美国vps和日本vps,香港物理机,国内高防物理机以及美国日本高防物理机产品特色:全配置均20M带宽,架构采用KVM虚拟化技术,全盘SSD硬盘,RAID10阵列, 国内回程三网CN2 GIA,平均延迟50ms以下。...

HostNamaste$24 /年,美国独立日VPS优惠/1核1G/30GB/1Gbps不限流量/可选达拉斯和纽约机房/免费Windows系统/

HostNamaste是一家成立于2016年3月的印度IDC商家,目前有美国洛杉矶、达拉斯、杰克逊维尔、法国鲁贝、俄罗斯莫斯科、印度孟买、加拿大魁北克机房。其中洛杉矶是Quadranet也就是我们常说的QN机房(也有CC机房,可发工单让客服改机房);达拉斯是ColoCrossing也就是我们常说的CC机房;杰克逊维尔和法国鲁贝是OVH的高防机房。采用主流的OpenVZ和KVM架构,支持ipv6,免...

rewrite规则为你推荐
租用主机一般公司网站租用主机选哪一种的?vps虚拟主机请问VPS和虚拟主机有什么不一样,为什么VPS贵那么多。广告的别来!域名主机域名,主机空间和网站文件三者之间的区别是什么深圳网站空间求免费稳定空间网站?香港虚拟主机想买一个香港虚拟主机,大家推荐一下吧天津虚拟主机天津哪个是新网互联代理呢,我打算购买邮局?中文域名什么是中文域名?域名劫持发现域名被劫持怎么办域名升级访问如何自动更新域名的IP?动态域名请问动态域名有什么作用啊?
域名交易 美国域名 godaddy域名解析教程 什么是域名地址 星星海 香港加速器 site5 监控宝 双12活动 京东云擎 免费静态空间 刀片式服务器 lol台服官网 国外代理服务器软件 流量计费 100m独享 linux服务器维护 空间登入 游戏服务器出租 xuni 更多