Nginx泛域名解析及Rewrite重定向普通页面及带参数的页面
[ 2014-09-13 15:36:16 | 作者: admin ]
本准备换Linux服务器,所以数据迁移暂时需要使用静态页面临时代替一下,之前的article.asp?id=xxx都要重定向到静态文件article/xxx.htm,下面看看Nginx是如何进行Rewrite的!
静态地址重定向到带参数的动态地址
rewrite "^(.*)/service/(.*)/.html$" $1/service.php?sid=$2 permanent;
带参数的动态地址重定向到静态地址
if ($query_string ~* id=(.*)) {
set $id $1;
rewrite "^(.*)/article.asp$" $1/article/$id.htm last;
}
泛域名解析
server_name www.w3cgroup.com *.w3cgroup.com;
server_name_in_redirect off;
#设置默认root
...
阅读全文…
静态地址重定向到带参数的动态地址
rewrite "^(.*)/service/(.*)/.html$" $1/service.php?sid=$2 permanent;
带参数的动态地址重定向到静态地址
if ($query_string ~* id=(.*)) {
set $id $1;
rewrite "^(.*)/article.asp$" $1/article/$id.htm last;
}
泛域名解析
server_name www.w3cgroup.com *.w3cgroup.com;
server_name_in_redirect off;
#设置默认root
...
阅读全文…
Nginx - rewrite 不区分大小写进行匹配
[ 2014-09-13 11:06:23 | 作者: admin ]
Use (?i) to match case-insensitively
eg: rewrite (?i)/(Cheap-[^\/]+\.html)(.*)$ /filter.php?route=$1 last;
参考范例
参考:
http://blog.csdn.net/w6611415/article/details/27367629
http://stackoverflow.com/questions/21577841/nginx-case-insensitive-url-redirection
eg: rewrite (?i)/(Cheap-[^\/]+\.html)(.*)$ /filter.php?route=$1 last;
参考范例
rewrite ^/html/newsList-(.*)\.html$ /html/newsList.php?cid=$1 last;
修改为rewrite (?i)^/html/newsList-(.*)\.html$ /html/newsList.php?cid=$1 last;
参考:
http://blog.csdn.net/w6611415/article/details/27367629
http://stackoverflow.com/questions/21577841/nginx-case-insensitive-url-redirection
1