1

I'd like to redirect all the pages that I have in my site example.com into https://www.example.com/..

In my htaccess file I have this code that works only from all the http pages to https pages but doesn't work from non-www pages to www pages (shows error "ERR_CONNECTION_REFUSED").

Options -MultiViews
RewriteEngine On

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

# Redirect to HTTPS 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Works in these cases (each of pages .php) from:

http://example.com/page.php to https://www.example.com/page.php http://www.example.com/page.php to https://www.example.com/page.php

Doesn't work only in these cases (each of pages .php) from:

https://example.com/page.php to https://www.example.com/page.php

Craig
  • 47
  • 1
  • 8
  • see if [https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www](https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) helps – Andra Apr 04 '18 at 09:15
  • Unluckily I had already tried those solutions but no one works. I think that problem is different of mine. Still have this problem, no idea how I'd do... @Andra – Craig Apr 04 '18 at 09:26
  • It was a DNS problem, htaccess code was right. Now everything works. – Craig Apr 09 '18 at 13:09

0 Answers0