开发者社区 问答 正文

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

"我现在想把登录页面和注册页面重定向到其他url,对nginxlocation不是很熟悉,试了好长时间,还是不行,请各位指点。我的配置如下: <pre class=""brush:shell; toolbar: true; auto-links: false;""># 配置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 11:23:40 795 分享 版权
1 条回答
写回答
取消 提交回答
  • "rewrite (.*) http://www.oschina.net$1 permanent; 即可,无需那个 $query_string 的东东
    ######回复 <a href=""http://my.oschina.net/dinga"" class=""referer"" target=""_blank"">@皮总 : 查oschina的配置,刚好在手边:)######老大,你在回复的时候查文档吗? 我经常要查查才能回答######<div class=""ref"">

    引用来自“红薯”的答案

    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 11:23:49
    赞同 展开评论