nginx rewrite url 把后缀全改成 htm

2014-08-25 15:38:21 +08:00
 zxc337
nginx rewrite url:
问题,想把这种 url 改写成
www.zuobian.com/tour/ --> www.zuobian.com/index.htm
www.zuobian.com/tour/xxx --> www.zuobian.com/tour/xxx.htm
www.zuobian.com/tour/xxx/ --> www.zuobian.com/tour/xxx.htm
www.zuobian.com/tour/xxx. --> www.zuobian.com/tour/xxx.htm
www.zuobian.com/tour/xxx.xxx --> www.zuobian.com/tour/xxx.htm
www.zuobian.com/account/ --> www.zuobian.com/account/login.htm
www.zuobian.com/account/home --> www.zuobian.com/account/home.htm
www.zuobian.com/account/home.html --> www.zuobian.com/account/home.htm
www.zuobian.com/account/home.xxx --> www.zuobian.com/account/home.htm
www.zuobian.com/account/home. --> www.zuobian.com/account/home.htm
www.zuobian.com/account/home --> www.zuobian.com/account/home.htm
www.zuobian.com/account/home/ --> www.zuobian.com/account/home.htm
www.zuobian.com/account/home/xxx --> www.zuobian.com/account/home/xxx.htm
www.zuobian.com/account/home/xxx.xxx --> www.zuobian.com/account/home/xxx.htm
www.zuobian.com/manage/ --> www.zuobian.com/manage/login.htm
www.zuobian.com/manage/company --> www.zuobian.com/manage/company.htm
www.zuobian.com/manage/company.html --> www.zuobian.com/manage/company.htm
www.zuobian.com/manage/company.xxx --> www.zuobian.com/manage/company.htm
www.zuobian.com/manage/company. --> www.zuobian.com/manage/company.htm
www.zuobian.com/manage/company --> www.zuobian.com/manage/company.htm
www.zuobian.com/manage/company/ --> www.zuobian.com/manage/company.htm
因为后端 java 只接收拦截.htm 请求;
自己写了一个 nginx rewrite 正则:
rewrite ^/(account|manage)(\/|\.|.[\w]*|[\w]*)$ http://$host/$1/login.htm break;
rewrite ^/tour/$ http://$host/index.htm break;
rewrite ^/(account|manage|tour)([\/|\w]*)(\.|\/|.[\w]*|[\w]*)$ /$1$2.htm break;

感觉不是很飘逸,跪求高手发一个比较好的配置,谢谢
4550 次点击
所在节点    NGINX
6 条回复
zxc337
2014-08-25 15:44:30 +08:00
没有玩nginx的高手吗?
msg7086
2014-08-26 08:19:46 +08:00
说句实话,需求太多太乱一般人懒得看……
seki
2014-08-26 10:15:13 +08:00
能用就好啦,合并成一条是好看,但是我觉得改天你就不知道这个 rule 是什么意思了,就算你还能读懂,以后接你手的人也会被坑一下的……
Liang
2014-08-26 11:50:42 +08:00
自寻烦恼,何必呢。。。
zxc337
2014-08-27 11:25:29 +08:00
客服需求,明白吗?求高手给个解决方案吧,谢谢
zxc337
2015-03-06 17:01:52 +08:00
Nginx+Lua+GraphicsMagick实现动态生成指定尺寸的图片,我这个方法可以吗? http://lawrence-zxc.github.io/2014/09/18/blog3/

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/129792

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX