简体   繁体   English

从Android API Rest调用重定向到https不起作用

[英]Redirect to https not working from Android API rest call

I am making my website http to https (using letsencrypt certificate ) with redirect from http to https with following: 我将我的网站从http重定向到https(使用letsencrypt certificate ),并使用以下命令从http重定向到https:

RewriteEngine on
RewriteCond %{SERVER_NAME} =xyz.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

I am making http API call to my website url from my android code, but it fails. 我正在从我的android代码对我的网站网址进行http API调用,但是失败。 When i change it to https, only then it succeeds. 当我将其更改为https时,只有成功。 Why is this happening and is there a way such that http call itself from my android code can succeed. 为什么会发生这种情况,并且有一种方法可以使我从Android代码中调用http本身成功。

My advice: 我的建议:

  • Always specify https in your android code 始终在您的android代码中指定https

  • For API, do NOT redirect http->https, but answer an error on the http version, it helps catch security errors faster (with a redirect they could stay undetected) 对于API,请勿重定向http-> https,但应回答http版本的错误,它有助于更​​快地捕获安全错误(通过重定向,它们可能不会被发现)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM