分享:常见PHP程序在Nginx环境下的伪静态规则汇总
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

很多时候我们找一些规则可以说“要的时候,怎么找也找不到,不用的时候,天天都随处可见”!这样的情况,想必多数伙伴们遇到过吧!的确这样的情况太多了!对于不同程序的伪静态规则在不同的环境中是有点差别的,今天小七通过收集整理了一下“常见PHP程序在Nginx环境下的伪静态规则”,也方便以后自己使用,毕竟度娘的东西说真的真心的不好用,出来的多数都是一些老掉牙的东西,对于老掉牙的排名还不错,对于一些新的说实在的就是把你脑袋抓破了都没得!
1、WordPress伪静态
复制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;}2、PHPCMS伪静态
复制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;3、DEDECMS伪静态
复制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;4、Discuz7伪静态
复制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;5、DiscuzX伪静态
复制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;}6、ECSHOP伪静态
复制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;}7、PHPWind伪静态
复制rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;8、SaBlog2.0伪静态
复制# 只带月份的归档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;# tagsrewrite ^/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;9、SHOPEX伪静态
复制if (!-e $request_filename) {rewrite ^/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ /index.php?$1 last;}10、Typecho伪静态
复制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;}以后其他的在随时补充,或者你有一些其他的也可以留言,一起集中在一起!说实在的凭借小七一个人之力实在是太渺小了,如果大家可以互相合作,那也许就是另外一片天地啦!
[Discuz]历史优惠活动内容
猜你可能想看的VPS
- 疯狂猜成语 图猜成语一个人站在起点和终点之间是什么成语?全球[VPS测评]
- 扫米工具→未注册域名批量查询全球[VPS测评]
- 便宜 $1.75 月 2 核 CPU 3G 内存 50G SSD 3T 全球[VPS测评]
- 搬瓦工 VPS 交易注意事项全球[VPS测评]
- js 动态改变文本颜色全球[VPS测评]
- Name 域名限时优惠→COM 域名$7.99 年全球[VPS测评]
- [降价]Vultr – $2.5 mo KVM 1 核 512M 20G全球[VPS测评]
- 送美元 RackNerd 春节促销→登陆 购买最高送$188 红包 独立独立服务器[U]
- PHP 获取图片指定点颜色及计算反色函数全球[VPS测评]
- hkserversolution→2.3 折优惠 美国原生 IP 解锁“美国VPS[主机]
- imidc→全场 VPS 一律 5 折 香港 VPS 台湾 VPS 日本日本VPS[主机]
- 触摸云春节特惠 全场VPS八五折特惠;香港gia和美国高防VPS ¥38美国VPS[主机]
- HKServerSolution → 4G内存 20G SSD 3T流量全球[VPS测评]
- CrownCloud -512M内存 1000G HDD 6T流量 1G全球[VPS测评]
- CombCloud,香港沙田cn2vps终身七折起,高质量网络稳定低延迟香港VPS[主机]
- 精美的宠物医院网站WordPress主题 - Valkuta全球[VPS测评]
- 又有美议员窜访台,中国驻美大使馆:“中方将对美国的挑衅采取果断的反制措施美国VPS[主机]
- 景林网络:香港CN2vps,1核1G3M月付35元;美国高防vps,48美国VPS[主机]
- 如何更改WHMCS默认后台路径让WHMCS系统更安全全球[VPS测评]
- MoonVM,香港HKT家宽VPS服务器,动态IP一键切换,1G带宽任意香港VPS[主机]
- 极光kvm怎么样?香港大带宽VPS促销1核1G内存19元/月起,5G防御香港VPS[主机]
- 好朋友51WORLD启动“地球克隆计划5”,我要去元宇宙参加了全球[VPS测评]
- 云服务器能干什么?有几十种玩法?阿里云,腾讯云服务器如何购买?全球[VPS测评]
- 香港vps免费:青云互联,1核1G/50G硬盘/500GB流量/2M带宽香港VPS[主机]
- 华凯易佰同比扭亏跨境电商行业回暖H2旺季将至中报追踪全球[VPS测评]
- 腾讯云香港服务器需要备案吗?腾讯云香港轻量服务器优惠活动香港VPS[主机]
- Ceraus:香港CN2云服务器,香港GIA VPS去程移动回程路线,月香港VPS[主机]
- 播放量破千万,点赞量破百万,你绝对想不到这三款多功能产品居然在TK上卖爆全球[VPS测评]
- 阁天互联怎么样?香港cn2云服务器 圣何塞cn2vps仅20/月香港VPS[主机]
- 咖啡主机:香港1G:15.6元/月(季付),美西1G:16.8元/月(季香港VPS[主机]
转载请注明原文地址:http://140.238.13.167:12355/read-77691.html











