将单页https重写为http Nginx

Sah*_*nha 4 php ssl joomla rewrite nginx

我想将"https://www.example.com"和"https://example.com"重写为"http://www.example.com"或"http://example.com".我只想写网站的特定部分而不是任何子文件夹或php相关页面.我该怎么做呢?

she*_*lic 7

我在另一个方向使用它(没有在这个方向测试,但应该工作).

if ( $scheme = https )
{
  rewrite ^ http://$host$uri;
}
Run Code Online (Sandbox Code Playgroud)

编辑:限制位置和结束不要尝试重写更多:

location / {
  if ( $scheme = https )
  {
    rewrite ^ http://$host$uri last;
  }
}
Run Code Online (Sandbox Code Playgroud)

  • @Ownatik:从你引用的页面:"在`location`上下文中`if`里面可以完成的唯一100%安全的东西是:`return ...;``rewrite ... last;`".这是第二种情况,你有更好的解决方案吗? (4认同)