0

I am currently editing an existing site to enable https in it. The website has three requirements for redirect

urls with .html to .php
http to https
non-www to www

The code I am currently using is this

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

But when I check www.websitename.com, it is not being redirected to https://www.websitename.com

I am trying many combinations for days (I have only basic knowledge of regexp), but it is showing one deficiency or another. Any help will be appreciated

phpkode
  • 250
  • 3
  • 12

1 Answers1

1

To redirect to https you can use:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291