Php AltoRouter的htacess重写,包括重定向到https

Php AltoRouter的htacess重写,包括重定向到https,php,.htaccess,altorouter,Php,.htaccess,Altorouter,我正在使用Altorouter,它需要在htacess中执行以下操作 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L] 这很好,但我还需要将http重定向到https。我在网上找到了一些例子,但我将两者结合起来的所有努力都失败了。如何将最上面的片段与此结合 RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule (.*) http

我正在使用Altorouter,它需要在htacess中执行以下操作

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
这很好,但我还需要将http重定向到https。我在网上找到了一些例子,但我将两者结合起来的所有努力都失败了。如何将最上面的片段与此结合

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://example.com/$1 [R]
试试下面的

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]