关于 Nginx 配置的一些疑惑, Nginx 根据cookie 进行rewrite
2024-10-20 08:10:22
网站目录结构如下:
/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
最新文章
- 9.25 DOM作业
- C# .net中获取台式电脑中串口设备的名称
- 20145208 《Java程序设计》第8周学习总结
- Android ListView的理解(一)
- java 零碎1
- Section 1.4 The Clocks
- jQuery Mobile 连接外部连接或切换动画
- 给logstash 模板添加触发器
- iOS_SN_Socket网络编程(一)
- css案例学习之span边框实现的特殊效果
- centos7安装zabbix3.2.4
- 常用u-boot命令详解(全) 2
- 使用定时器限制点击按钮发送短信(附源码)--JavaScript小案例
- 我们为什么要用springcloud?
- Linux系统下zookeeper的安装和配置
- uby on rails 用户密码加密
- mipi LCD 的CLK时钟频率与显示分辨率及帧率的关系【转】
- 用MVC5+EF6+WebApi 做一个考试功能(六) 仓储模式 打造EF通用仓储类
- 撩课-Web大前端每天5道面试题-Day23
- Jupyter安装及运行
热门文章
- AntDesign vue学习笔记(五)导航菜单动态加载
- HTML5 Canvas实战之刮奖效果【转】
- 示例:自定义WPF底层控件UI库 HeBianGu.General.WpfControlLib V2.0版本
- Asp.Net Core中使用GDI+绘图提示gdiplus库找不到的问题
- 同级frame之间的通信与跳转
- IDEA连接MySQL数据库报错08001
- 关于银企直连中银行通信类 配置篇 EPIC_PROC
- spark存储模块之内存存储--MemeoryStore
- vim替换字符串
- Mac原型动画设计软件Drama创建3D图层的注意事项,你知道吗?