网站目录结构如下:
/public/en.html
/public/zh_cn.html
/public/index.php

之前所有的非静态资源请求都交给 index.php
现在要把首页的请求 不走PHP了,提高下网站性能。Nginx会根据cookie值 lang=en 直接返回en.html 根据 lang=zh_cn 直接返回 zh_cn.html。如果没有cookie的话,默认返回 zh_cn.html.
首页请求地址有3个,分别为: 

/index
/index/index 
求Nginx 配置。
现在的Ngxin配置如下:

location / {
index index.php;
if ($http_cookie ~* "lang=en"){
rewrite ^/$ /en.html;
rewrite /index /en.html;
rewrite /index/index /en.html;
}
if ($http_cookie ~* "lang=zh_cn"){
rewrite ^/$ /zh_cn.html;
rewrite /index /zh_cn.html;
rewrite /index/index /zh_cn.html;
} root /www/wwwroot/public;
try_files $uri $uri/ /index.php?q=$uri&$args;
}

  

但是不好使啊,网上说 location里,if 和 try_files同时使用会有问题,http://wiki.nginx.org/IfIsEvil
搞了一天了,还是没整好,好郁闷。感觉到了瓶颈了。

https://www.oschina.net/question/186778_226741

最新文章

  1. 9.25 DOM作业
  2. C# .net中获取台式电脑中串口设备的名称
  3. 20145208 《Java程序设计》第8周学习总结
  4. Android ListView的理解(一)
  5. java 零碎1
  6. Section 1.4 The Clocks
  7. jQuery Mobile 连接外部连接或切换动画
  8. 给logstash 模板添加触发器
  9. iOS_SN_Socket网络编程(一)
  10. css案例学习之span边框实现的特殊效果
  11. centos7安装zabbix3.2.4
  12. 常用u-boot命令详解(全) 2
  13. 使用定时器限制点击按钮发送短信(附源码)--JavaScript小案例
  14. 我们为什么要用springcloud?
  15. Linux系统下zookeeper的安装和配置
  16. uby on rails 用户密码加密
  17. mipi LCD 的CLK时钟频率与显示分辨率及帧率的关系【转】
  18. 用MVC5+EF6+WebApi 做一个考试功能(六) 仓储模式 打造EF通用仓储类
  19. 撩课-Web大前端每天5道面试题-Day23
  20. Jupyter安装及运行

热门文章

  1. AntDesign vue学习笔记(五)导航菜单动态加载
  2. HTML5 Canvas实战之刮奖效果【转】
  3. 示例:自定义WPF底层控件UI库 HeBianGu.General.WpfControlLib V2.0版本
  4. Asp.Net Core中使用GDI+绘图提示gdiplus库找不到的问题
  5. 同级frame之间的通信与跳转
  6. IDEA连接MySQL数据库报错08001
  7. 关于银企直连中银行通信类 配置篇 EPIC_PROC
  8. spark存储模块之内存存储--MemeoryStore
  9. vim替换字符串
  10. Mac原型动画设计软件Drama创建3D图层的注意事项,你知道吗?