-1

Today I turned on SSL.

But I have a big problem, i do not know how to set the absolute all subpages diverted permanently to: https://example.com in htaccess.

So I want all this:

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

to be redirected to https://example.com

Like all subpages (I have 300 sub pages).

  • Possible duplicate of [How to redirect all HTTP requests to HTTPS](http://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https) – jww Aug 17 '14 at 21:19

2 Answers2

0

Try this, works with every domain name:

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]
communications
  • 145
  • 1
  • 10
0

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [NE,R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643