문제

I'm using restler to write a REST api, and since I wan't to do some basic authentication I need to redirect every request wich doesn't come from https, to https.

Does anybody know a way of doing this using the .htaccess file provided by restler or is it better to do this redirection using php headers?

Thanks in advance!

도움이 되었습니까?

해결책

Approach that works for me is to do it from index.php (gateway) place the code below in your index.php before any other code

if($_SERVER['HTTPS']!="on")
{
   $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
   header("Location:$redirect");
   exit;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top