Nginxt rewrite企业应用实例
2016-07-01 11:08
676 查看
需求:最近接到运营的需求,由于百度上搜索公司wap页面的url的地址为www.mycompany.com/mobile,当用户访问该域名时,需跳转到公司wap页面m.mycompany.com。解决思路:在公司网站首页(www.mycompany.com),根据http_user_agent的值区分手机浏览器,直接跳转到m.haiwaiu.com;
在wap首页(m.mycompany.com),根据request_uri实现url的跳转。
实现代码:第一步代码实现if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry)') {
rewrite ^.+ http://m.mycompany.com$uri; }
第二步代码实现
if ($request_uri ~* 'mobile') {
rewrite ^/(mobile)(.*)$ http://m.mycompany.com$2 permanent;
}
在wap首页(m.mycompany.com),根据request_uri实现url的跳转。
实现代码:第一步代码实现if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry)') {
rewrite ^.+ http://m.mycompany.com$uri; }
第二步代码实现
if ($request_uri ~* 'mobile') {
rewrite ^/(mobile)(.*)$ http://m.mycompany.com$2 permanent;
}
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 用zabbix监控nginx_status状态
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- wordpress rewrite问题解决
- web 应用中常用的各种 cache详解
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略
- window+nginx+php环境配置 附配置搭配说明
- 比较详细的Asp伪静态化方法及Asp静态化探讨
- ISAPI-REWRITE伪静态规则写法以及说明