bramus / router

A lightweight and simple object oriented PHP Router
MIT License
1.09k stars 245 forks source link

HTTPS auto redirect with .htaccess #191

Closed pTinosq closed 2 years ago

pTinosq commented 2 years ago

Hello everyone,

I'm still getting used to how the router works at the moment and I've been trying to get https redirecting working with no luck. I would really appreciate it if someone could explain what I would need to change in order to get this feature working.

Here is my .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# Router
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [NC,L]

ErrorDocument 404 /404.html

# Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>

#Prevent directory listings
Options All -Indexes

I assume the line RewriteRule ^ index.php [NC,L] will need to be updated, I just have no idea where to start.

bramus commented 2 years ago

This is an Apache configuration problem, not a bramus/router issue. Please refer to https://www.bram.us/2021/02/15/apache-htaccess-enforce-https/ for a solution.