这是通过htaccess重定向到https和www的好方法,

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^(.*)index.php$ https://www.%1%{REQUEST_URI} [NE,R=301,L]

但是可以添加任何东西,以便它还可以将/index.php重定向到根目录吗?

例如,我需要https://example.com/index.phphttps://example.com/

我想把所有东西都变成1 RewriteRule,以避免任何重定向链 .

谢谢!