0

If I type http://example.com it will become http://www.example.com.

The www redirect is working, but not the https one.

But it is working in my articles (home.php), if I type www.example.com/article/1/article-name it will become https://www.example.com/article/1/article-name as I wanted.

Why it is not working on index.php?

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteRule ^page/(.*) /index.php?pagina=$1
RewriteRule ^article/(.*) /home.php?id=$1

RewriteRule ^sitemap\.xml$ sitemap.php [L]

RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

ErrorDocument 404 /404.php

AddCharset UTF-8 .htm
AddCharset UTF-8 .html
AddCharset UTF-8 .php

Options -MultiViews

options -indexes
RGS
  • 4,062
  • 4
  • 31
  • 67
  • Possible duplicate of [htaccess redirect to https://www](https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) – Girish Dec 05 '18 at 11:51

1 Answers1

0

Try to add

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Source: Redirect All Web Traffic

Ced
  • 1,293
  • 5
  • 23
  • 34