I have used this code in my .htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^silkgifts.co.uk
RewriteRule (.*) https://www.silkgifts.co.uk/$1 [R=301,L]
it directs my HTTPS non-www to the HTTPS www site also it directs the HTTP non-www to the HTTPS www site. However, it is not directing the HTTP www to the https www.
I also put in this code to try and solve the problem:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
which worked in Google Search Console but when testing on other sites it said there was an endless chain of redirects so I removed it.
Can anyone tell me where I am going wrong?
EDIT: Current .htaccess
file:
AddHandler php56-script .php .php5
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
RewriteEngine On
RewriteCond %{HTTP_HOST} ^silkgifts.co.uk
RewriteRule (.*) https://www.silkgifts.co.uk/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]