同时重定向从(.html到.php)和(http到https)和(非www到www)使用htaccess


Simultaneous redirect from (.html to .php) and (http to https) and (non-www to www) using htaccess

我目前正在编辑一个现有的网站,以便在其中启用https。网站对重定向

有三个要求

从。html到。php的url
HTTP到https
从非www到www

我现在使用的代码是这个

RewriteEngine on
RewriteRule ^(.*)'.html$ $1.php [L]
RewriteCond %{HTTP_HOST} ^websitename'.com$ [NC]
RewriteRule ^(.*)$ https://www.websitename.com/$1 [L,R=301]

但是当我检查www.websitename.com时,它没有被重定向到https://www.websitename.com

我尝试了许多天的组合(我只有regexp的基本知识),但它显示出一个或另一个缺陷。如有任何帮助,不胜感激

要重定向到https,可以使用:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]