klein / klein.php

A fast & flexible router
MIT License
2.66k stars 290 forks source link

How to force redirect to https #385

Closed lakuapik closed 6 years ago

lakuapik commented 6 years ago

This is my .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

How can i force to use https instead of just http?

I already search google and not yet get any solution. Please help me. Thanks.

ErikThiart commented 6 years ago

Please try this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
lakuapik commented 6 years ago

Thanks @ErikThiart, it works like a charm!