2

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!

danielrvt
  • 10,177
  • 20
  • 80
  • 121

1 Answers1

2

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;
}
Arul Kumaran
  • 983
  • 7
  • 23