nginx rewrite url 把后缀全改成 htm
- 0次
- 2021-05-28 02:11:39
- idczone
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/hom大带宽服务器e. --> 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;
感觉不是很飘逸,跪求高手发一个比较好的配置,谢谢
没有玩nginx的高手吗?
说句实话,需求太多太乱一般人懒得看……
能用就好啦,合并成一条是好看,但是我觉得改天你就不知道这个 rule 是什么意思了,就算你还能读懂,以后接你手的人也会被坑一下的……
自寻烦恼,何必呢。。。
客服需求,明白吗?求高手给个解决方案吧,谢谢
Nginx+Lua+GraphicsMagick实现动态生成指定尺寸的图片,我这个方法可以吗? http://lawrence-zxc.github.io/2014/09/18/blog3/