http to https automatic redirect in htaccess

130 views
Skip to first unread message

Roman Alekseev

unread,
Jan 28, 2018, 2:40:04 PM1/28/18
to Fat-Free Framework
What is right htaccess config for http to https automatic redirect?

If i'm doing like:

RewriteEngine On

RewriteRule ^(tmp)\/|\.ini$ - [R=404]

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

I get error in chrome: ERR_TOO_MANY_REDIRECTS

ved

unread,
Jan 28, 2018, 4:18:59 PM1/28/18
to Fat-Free Framework
That's a webserver issue and pretty much nothing to do with F3.

Tim

unread,
Jan 29, 2018, 4:46:48 PM1/29/18
to f3-fra...@googlegroups.com
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Works fine

Roman Alekseev

unread,
Jan 30, 2018, 3:16:59 AM1/30/18
to Fat-Free Framework
RewriteEngine On


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

RewriteRule ^(tmp)\/|\.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]


the code above cause a rewrite loop

вторник, 30 января 2018 г., 0:46:48 UTC+3 пользователь Tim написал:

Roman Alekseev

unread,
Jan 30, 2018, 3:21:35 AM1/30/18
to Fat-Free Framework
No it is not webserver issue! 
F3 has its own htaccess config. It redirects to index.php.
The question is how automatic redirect http to https in htaccess FOR FAT FREE FRAMEWORK!!!

понедельник, 29 января 2018 г., 0:18:59 UTC+3 пользователь ved написал:

ved

unread,
Jan 30, 2018, 3:45:14 AM1/30/18
to Fat-Free Framework
Well ok. Then explain why I'm not even using Apache and don't have any .htaccess and I can still both use F3 and redirect to https?

F3's htaccess is just for that, redirecting requests to the index.php. Also, the .htaccess file is a part of Apache, not F3.

If you had actually read the page I linked. You know, the one on the OFFICIAL APACHE DOCUMENTATION!!! Then you'd already have at least 2 different ways to do that redirection.

But that's fine, I'm sure you'll get there eventually.

Good luck.



On Tuesday, January 30, 2018 at 8:21:35 AM UTC, Roman Alekseev wrote:
FOR FAT FREE FRAMEWORK!!!

Tim

unread,
Jan 30, 2018, 6:22:51 AM1/30/18
to Fat-Free Framework
Are you using Cloudflare or a similar CDN?

Roman Alekseev

unread,
Jan 30, 2018, 7:48:13 AM1/30/18
to Fat-Free Framework
OK, at the end I found working (without rewrite loop) config for me (my hosting?): 

RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Protocol} !=https
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]


RewriteRule ^(tmp)\/|\.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

May be it will helps someone...
 
Reply all
Reply to author
Forward
0 new messages