Url rewriting nginx重写utf-8端编码url
我正在使用Nginx,我想用以下两个参数重写所有url:Url rewriting nginx重写utf-8端编码url,url-rewriting,nginx,rewrite,Url Rewriting,Nginx,Rewrite,我正在使用Nginx,我想用以下两个参数重写所有url: title=%E7%89%B9%E6%AE%8A 及 到主页 我不知道怎么写规则,有人能帮我吗 编辑: 我想重写URL,如: http://example.com/index.php?days=30&from=20120122083408&limit=250&title=%E7%89%B9%E6%AE%8A 或 或 到 Nginx不支持逻辑AND操作,但我们可以使用“little hack”: 这将有助于您:
title=%E7%89%B9%E6%AE%8A
及
到主页
我不知道怎么写规则,有人能帮我吗
编辑:
我想重写URL,如:
http://example.com/index.php?days=30&from=20120122083408&limit=250&title=%E7%89%B9%E6%AE%8A
或
或
到
Nginx不支持逻辑AND操作,但我们可以使用“little hack”: 这将有助于您:
location = /index.php {
set $redirect "";
# if we have get parameter "title":
if ( $arg_title ) {
set $redirect "Y";
}
# if we have get paramter "from":
if ( $arg_from ) {
set $redirect "${redirect}ES";
}
# Now in the variable $redirect should be a word "YES":
if ( $redirect = YES ) {
rewrite ^ / last;
}
....
}
另外,您也可以使用302重定向,直接将用户移动到/请给出一个例子,url在重写前后应该是什么样子?好的。我只是增加了一些例子。见上面。好主意。谢谢,谢尔盖。现在唯一的问题是,我只想在$arg_title等于“%E7%89%B9%E6%AE%8A”(已解码为中文单词的字符串)时重写url特殊'). 我怎么能做到呢?我试过
如果($arg_title~“(*UTF8)^\x{7279}\x{6b8a}$”
,但没有成功。很棒的黑客!非常感谢!
http://example.com/index.php?from=20120622063000&limit=20&title=%E7%89%B9%E6%AE%8A
http://example.com/index.php?from=20030422063000&title=%E7%89%B9%E6%AE%8A
http://example.com
location = /index.php {
set $redirect "";
# if we have get parameter "title":
if ( $arg_title ) {
set $redirect "Y";
}
# if we have get paramter "from":
if ( $arg_from ) {
set $redirect "${redirect}ES";
}
# Now in the variable $redirect should be a word "YES":
if ( $redirect = YES ) {
rewrite ^ / last;
}
....
}