Slim.url_scheme always showing http even accessed from https

Hi All,

I want restrict to allow only https. So, I am trying to add condition by checking slim.url_scheme. But slim.url_scheme always showing http even I accessed from https. Can you please help what i need to modify.


I don’t know if there is a way to force https via Slim (newbie), but if you have access to the server, specifically httpd.conf or vhosts (in Apache), you can use: Redirect permanent / https://urlGoesHere in the <VirtualHost *:80> section. Else, I would use PHP code to redirect:

if ($_SERVER[‘SERVER_PORT’] != 443) {
$redir = “Location: https://” . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘PHP_SELF’];

From request you can pick up connection protocol like this


This works very well.

1 Like