开发者社区> 问答> 正文

nginx location匹配指定页面配置 - nginx报错

我现在想把登录页面和注册页面重定向到其他url,对nginxlocation不是很熟悉,试了好长时间,还是不行,请各位指点。我的配置如下:

# 配置URL规则:访问登录和注册页面重定向https访问 location ^~ /yddweb/index/(login.jsp|register.jsp) { root   yddweb; set $query $query_string; if ($query_string != '' ) { rewrite ^/(.)$ https://$host$document_uri?$query? permanent; } if ($query_string = '' ) { rewrite ^/(.)$ https://$host$document_uri permanent; } }

展开
收起
montos 2020-05-31 22:17:28 736 0
1 条回答
写回答
取消 提交回答
  • rewrite (.*) http://www.oschina.net$1 permanent; 即可,无需那个 $query_string 的东东
    ######回复 @皮总 : 查oschina的配置,刚好在手边:)######老大,你在回复的时候查文档吗? 我经常要查查才能回答######

    引用来自“红薯”的答案

    rewrite (.*) http://www.oschina.net$1 permanent; 即可,无需那个 $query_string 的东东
    红薯大哥,我的location ^~ /yddweb/index/login.jsp|register.jsp这儿好像我访问 http://localhost/yddweb/index/login.jsp?ReturnUrl=http://localhost/yddweb/不起作用,没有实现重定向,我这样匹配有什么问题?
    2020-05-31 22:17:39
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载