nginx的一些规则案例 备忘
2013-04-09 14:06
405 查看
xxx: http://home.hao123.com/wiki/wiki.asp?/=xxx 301到 http://home.hao123.com/wiki/index/c/xxx location ~ wiki\.asp {
if ( $query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/wiki/index/c/$cc permanent;
}
} http://home.hao123.com/wiki/wikiview.asp?/=xxx 301到 http://home.hao123.com/wiki/view/id/xxx location ~ wikiview\.asp {
if ($query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/wiki/view/id/$cc permanent;
}
}
1列表页:http://home.hao123.com/zhuangshi/list.asp 301到 http://jmall.sina.com/Company/cList/ rewrite ^/zhuangshi/list\.asp http://jmall.sina.com/Company/cList/ permanent;
2列表页:http://home.hao123.com/design/ 301到 http://jmall.sina.com/Company/styleList rewrite ^/design http://jmall.sina.com/Company/styleList permanent;
图库首页 http://home.hao123.com/photo/zhuangxiu.asp 301到 http://home.hao123.com/photo/ rewrite ^/photo/zhuangxiu\.asp http://home.hao123.com/photo/ permanent;
图库分类页 http://home.hao123.com/photo/jiaju.asp 301到 http://home.hao123.com/photo/showlist/pid/6 rewrite ^/photo/jiaju\.asp http://home.hao123.com/photo/showlist/pid/6 permanent;
图库内页 http://home.hao123.com/photo/phoList.asp?/=xxx 301到 http://home.hao123.com/photo/show/id/xxx#p=1 location ~ /photo/phoList\.asp {
if ( $query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/photo/show/id/$cc#p=1 permanent;
}
} http://home.hao123.com/photo/list.asp?classId=xxx 301到 http://home1.hao123.com/photo/showlist/cid/xxx location ~ /photo/list\.asp {
if ( $query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/photo/showlist/cid/$cc permanent;
}
} http://home.hao123.com/*** 以上未定义的 直接跳转到 http://home.hao123.com/ if (!-e $request_filename) {
rewrite ^(.*)$ http://home1.hao123.com last;
}
ps:xxx 代表数字ID
http://ng1.qq.com/tv/list.asp?areaid=33 301 到 http://ng1.qq.com/tv/lists/areaid/33
if ($request_uri ~ "^/tv/list\.asp\?areaid=([\d]+)$")
{
set $q $1;
rewrite .* /tv/lists/areaid/$q? permanent;
}
访问 http://ng.qq.com/html/2013-07-29/1035590.html 内容显示 http://ng.qq.com/html/2013/07/29/1035590.html rewrite "^/html/(\d+)-(\d+)-(\d+)/(.*).html$" /html/$1/$2/$3/$4.html last;
http://news.qq.com/index.php?m=html&a=Other&date=130806&par=31MTR1375752599_1 重写成 http://news.qq.com/html/Other/130806/31MTR1375752599_1.html rewrite ^(.*)/(\w+)/(\w+)/(\d+)/(\w+)\.html$ $1/index.php?m=$2&a=$3&date=$4&par=$5 last;
访问 3g.ah.qq.com跳到m.ah.qq.com
if ($host ~* "^3g\.(.*)\.qq\.com") {
set $domain $1;
rewrite ^/(.*) http://m.$domain.qq.com/$1 last;
}
http://www.ah.cn/newsshow.php?siteid=2&cid=4&id=9&page=1伪静态成 http://www.ah.cn/newsshow-4-9-1.html
rewrite ^/newsshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /newsshow.php?siteid=2&cid=$1&id=$2&page=$3 last;
if ( $query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/wiki/index/c/$cc permanent;
}
} http://home.hao123.com/wiki/wikiview.asp?/=xxx 301到 http://home.hao123.com/wiki/view/id/xxx location ~ wikiview\.asp {
if ($query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/wiki/view/id/$cc permanent;
}
}
1列表页:http://home.hao123.com/zhuangshi/list.asp 301到 http://jmall.sina.com/Company/cList/ rewrite ^/zhuangshi/list\.asp http://jmall.sina.com/Company/cList/ permanent;
2列表页:http://home.hao123.com/design/ 301到 http://jmall.sina.com/Company/styleList rewrite ^/design http://jmall.sina.com/Company/styleList permanent;
图库首页 http://home.hao123.com/photo/zhuangxiu.asp 301到 http://home.hao123.com/photo/ rewrite ^/photo/zhuangxiu\.asp http://home.hao123.com/photo/ permanent;
图库分类页 http://home.hao123.com/photo/jiaju.asp 301到 http://home.hao123.com/photo/showlist/pid/6 rewrite ^/photo/jiaju\.asp http://home.hao123.com/photo/showlist/pid/6 permanent;
图库内页 http://home.hao123.com/photo/phoList.asp?/=xxx 301到 http://home.hao123.com/photo/show/id/xxx#p=1 location ~ /photo/phoList\.asp {
if ( $query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/photo/show/id/$cc#p=1 permanent;
}
} http://home.hao123.com/photo/list.asp?classId=xxx 301到 http://home1.hao123.com/photo/showlist/cid/xxx location ~ /photo/list\.asp {
if ( $query_string ~* "=(\d+)$" ) {
set $cc $1;
set $args '';
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/photo/showlist/cid/$cc permanent;
}
} http://home.hao123.com/*** 以上未定义的 直接跳转到 http://home.hao123.com/ if (!-e $request_filename) {
rewrite ^(.*)$ http://home1.hao123.com last;
}
ps:xxx 代表数字ID
http://ng1.qq.com/tv/list.asp?areaid=33 301 到 http://ng1.qq.com/tv/lists/areaid/33
if ($request_uri ~ "^/tv/list\.asp\?areaid=([\d]+)$")
{
set $q $1;
rewrite .* /tv/lists/areaid/$q? permanent;
}
访问 http://ng.qq.com/html/2013-07-29/1035590.html 内容显示 http://ng.qq.com/html/2013/07/29/1035590.html rewrite "^/html/(\d+)-(\d+)-(\d+)/(.*).html$" /html/$1/$2/$3/$4.html last;
http://news.qq.com/index.php?m=html&a=Other&date=130806&par=31MTR1375752599_1 重写成 http://news.qq.com/html/Other/130806/31MTR1375752599_1.html rewrite ^(.*)/(\w+)/(\w+)/(\d+)/(\w+)\.html$ $1/index.php?m=$2&a=$3&date=$4&par=$5 last;
访问 3g.ah.qq.com跳到m.ah.qq.com
if ($host ~* "^3g\.(.*)\.qq\.com") {
set $domain $1;
rewrite ^/(.*) http://m.$domain.qq.com/$1 last;
}
http://www.ah.cn/newsshow.php?siteid=2&cid=4&id=9&page=1伪静态成 http://www.ah.cn/newsshow-4-9-1.html
rewrite ^/newsshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /newsshow.php?siteid=2&cid=$1&id=$2&page=$3 last;
相关文章推荐
- 国内一些常用PHP的CMS的Nginx服务器的伪静态规则整理
- nginx-rewrite规则案例
- nginx静态文件配置 rewrite规则语法 及配置案例讲解
- 我们在提供api或微服务时,通常借助openresty nginx进行流量转发或者添加一些规则或功能,
- 关于CAShapeLayer的一些实用案例和技巧
- 备忘一些方法
- 一些for循环案例
- 知识一些备忘
- nginx location匹配规则
- jQuery的一些备忘
- 初习C++点滴摘录之编程的一些规则与建议(3)
- nginx配置location总结及rewrite规则写法
- 转:初学ASP.Net时在论坛收藏收集的一些资料备忘
- vi 一些命令(备忘,自己用的)
- 关于Nginx的一些优化(突破十万并发)。
- nginx记录真是的IP地址 <备忘>
- 开放源码必须遵守的一些规则
- codeigniter nginx rewrite规则配置【转】
- 初学ASP.Net时在论坛收藏收集的一些资料备忘
- 调试nginx匹配规则的一个思路