0

I want to redirect 301:

http://example.com
http://www.example.com

TO

https://www.example.com

I put this code, but it does not work (error 500)

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off           [OR]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/%{REQUEST_URI} [R=301,L, NE]

1 Answers1

0

This:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Source: this blog

OR

Based on this answer:

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName www.example.com
    # ... SSL configuration goes here
</VirtualHost>
Community
  • 1
  • 1
Ani Menon
  • 27,209
  • 16
  • 105
  • 126