2
votes

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!

1

1 Answers

2
votes

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;
}