-
example 1
-
跳转到
-
if ($query_string ~* "id=(\d+)$") {
-
set $digit $1;
-
rewrite "^/index\.php" permanent;
-
}
-
example 2
-
把访问的请求跳转到
-
if ($request_uri ~ "/a\?key=(\d+)"){
-
set $number $1;
-
rewrite ^/(.*) last; # 注意那个 “?” 旧链接自带的参数会默认追加到新链接后面,加上?避免这种情况
-
}
-
-
example 3
-
业务平台部门需要一个seo优化,提高seo权重, 所以需要一些以其他语言编写的后缀页面也rewrite到首页
-
if ($uri ~ php$) {
-
rewrite ^/(.*)$ permanent;
-
}
-
-
example 4
-
url 中参数t参数值等于 ufruit.net,跳转首页
-
if ($arg_t ~ "www\.ufruit\.net") {
-
rewrite ^/(.*)$ permanent;
-
}
example 5
"rewrite"
if ( $request_uri ~ "index\.php\?r=([^/]+)/([^&]+)&v=bi" ) {
set $s "$1";
set $p "$2";
rewrite ^/(.*)$ permanent;
}
2014/08/20 23:49:31 [notice] 11049#0: *16 "index\.php\?r=([^/]+)/([^&]+)&v=bi" matches "/index.php?r=site/product&v=bi", client: 172.16.100.123, server: request: "HEAD /index.php?r=site/product&v=bi HTTP/1.1", host: ""
2014/08/20 23:49:31 [notice] 11049#0: *16 "^/(.*)$" matches "/index.php", client: 172.16.100.123, server: request: "HEAD /index.php?r=site/product&v=bi HTTP/1.1", host: ""
2014/08/20 23:49:31 [notice] 11049#0: *16 rewritten redirect: "", client: 172.16.100.123, server: request: "HEAD /index.php?r=site/product&v=bi HTTP/1.1", host: ""
-