0
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* ? [F,L]
RewriteCond %{HTTPS} off 

RewriteCond %{HTTPS_HOST} !^www.website.com$ [NC]
RewriteRule ^(.*)$ https://www.website.com/$1 [L,R=301]

I used this to redirect:

I tried this code changing http to https, but still it does not work. Is there anything that I'm doing wrong?

Rahul
  • 311
  • 2
  • 3
  • 8

2 Answers2

1

You can use:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* ? [F,L]

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTPS_HOST} !^www.website.com$ [NC]
RewriteRule ^(.*)$ https://www.website.com/$1 [L,R=301]

With [OR]

Croises
  • 18,570
  • 4
  • 30
  • 47
0
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code worked for me. Thank you!

Rahul
  • 311
  • 2
  • 3
  • 8