静态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;

}

}

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

ZJI:台湾CN2/香港高主频服务器7折每月595元起,其他全场8折

ZJI原名维翔主机,是原来Wordpress圈知名主机商家,成立于2011年,2018年9月更名为ZJI,提供香港、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册业务。ZJI今年全新上架了台湾CN2线路服务器,本月针对香港高主频服务器和台湾CN2服务器提供7折优惠码,其他机房及产品提供8折优惠码,优惠后台湾CN2线路E5服务器月付595元起。台湾一型CPU:Inte...

LOCVPS新上韩国KVM,全场8折,2G内存套餐月付44元起_网络传真服务器

LOCVPS(全球云)发布了新上韩国机房KVM架构主机信息,提供流量和带宽方式,适用全场8折优惠码,优惠码最低2G内存套餐月付仅44元起。这是一家成立较早的国人VPS服务商,目前提供洛杉矶MC、洛杉矶C3、和香港邦联、香港沙田电信、香港大埔、日本东京、日本大阪、新加坡、德国和荷兰等机房VPS主机,基于KVM或者XEN架构。下面分别列出几款韩国机房KVM主机配置信息。韩国KVM流量型套餐:KR-Pl...

随风云25元/月 ,德阳高防云服务器 2核2G 10M 75元/月 内蒙古三线BGP服务器 2核2G 5M

公司介绍成都随风云科技有限公司成立于2021年,是国内领先的互联网业务平台服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、双线高防、香港等优质的IDC资源。公司一直秉承”以人为本、客户为尊、永续创新&...

rewrite规则为你推荐
linux虚拟主机linux下最好的虚拟机是什么呢 VMware 还是virtualbox域名空间什么是空间 什么是域名英文域名中文域名和英文域名的区别? 越详细越好域名服务商域名服务商所属区域怎么填写jsp虚拟空间请问如何卖掉JSP虚拟主机香港虚拟主机香港的虚拟主机好不好,如何选择虚拟主机?虚拟主机评测网哪里有可靠的免费虚拟主机虚拟主机控制面板虚拟主机管理面板与网站后台有什么区别?论坛虚拟主机虚拟主机禁止放论坛淘宝虚拟主机淘宝里卖虚拟主机、独立服务器、VPS的都是怎么进货的。
国内vps 免费申请域名和空间 warez sharktech 国外永久服务器 视频存储服务器 godaddy优惠码 流媒体服务器 腾讯云数据库 表单样式 java虚拟主机 777te 免费美国空间 idc查询 银盘服务是什么 空间租赁 外贸空间 太原联通测速 cxz 工信部icp备案查询 更多