I have a Wordpress site functioning as a blog site on a website. The main website is just basic HTML it is only www.example/blog which has the WordPress site.
I have installed an SSL certificate for the domain and it is working fine. I have a .htaccess file in the root folder redirecting from HTTP to https for the main site and another in the /blog folder redirecting the Wordpress site.
The problem I am having is the main folder www.example/blog will redirect to https however none of the blog posts will redirect.
So for example if I enter into the browser i get .
But if I enter I get it does not redirect.
I have tried a number of different .htaccess commands, but they all give the same result. I currently have the following script in the .htaccess folder.
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Any help on this would be greatly appreciated.
I have a Wordpress site functioning as a blog site on a website. The main website is just basic HTML it is only www.example/blog which has the WordPress site.
I have installed an SSL certificate for the domain and it is working fine. I have a .htaccess file in the root folder redirecting from HTTP to https for the main site and another in the /blog folder redirecting the Wordpress site.
The problem I am having is the main folder www.example/blog will redirect to https however none of the blog posts will redirect.
So for example if I enter http://www.example/blog into the browser i get https://www.example/blog.
But if I enter http://www.example/blog/blog-post I get http://www.example/blog/blog-post it does not redirect.
I have tried a number of different .htaccess commands, but they all give the same result. I currently have the following script in the .htaccess folder.
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Any help on this would be greatly appreciated.
Share Improve this question asked Apr 24, 2020 at 19:13 Pete BPete B 111 bronze badge2 Answers
Reset to default 0You should set your blog url to https://yourdomain You can do this in the /wp-admin/options-general.php page the setting is WordPress Address (URL) and Site Address (URL)
So I finally got it working, the solution was quite simple and I am not sure why it made a difference. but I am not an expert so maybe someone else can weigh in on it at some stage.
Basically I just moved the Rewrite rule in the .htaccess file to the top. There are a few other rules in the file and originally it was below the others.
The code I ended up using that has worked when placed at the very top of the .htaccess file is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>