Supposedly this forces https:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
This is my current .htaccess file
RewriteOptions inherit
<IfModule LiteSpeed>
RewriteEngine on
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mywebsite.co.uk [NC]
RewriteRule ^(.*)$ https://www.myswebsiye.co.uk/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co\.uk$
RewriteRule ^index\.html$ "https\:\/\/www\.mywebsite\.co\.uk\/" [R=301,L]
The sitewide ridrect works well but if someone did type http://www.mysite.com/pagetwo/ it wouldn’t redirect to the https version basically i need to do a redirect for each page
Ahh.. try moving the WordPress stuff to the bottom.
RewriteOptions inherit
<IfModule LiteSpeed>
RewriteEngine on
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mywebsite.co.uk [NC]
RewriteRule ^(.*)$ https://www.myswebsiye.co.uk/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co\.uk$
RewriteRule ^index\.html$ "https\:\/\/www\.mywebsite\.co\.uk\/" [R=301,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This seems to have solved the issue, big thanks to you! But the only other issue is if I type
www.mywebsite.co.uk it forwards to this https://.www.myswebsite.co.uk/ error page reads
This site can’t be reached
.www.mywebsite.co.uk’s server DNS address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN
Try and change this line:
RewriteRule ^index\.html$ "https\:\/\/www\.mywebsite\.co\.uk\/" [R=301,L]
To:
RewriteRule ^index\.html$ https://www\.mywebsite\.co\.uk/ [R=301,L]