Answer the question
In order to leave comments, you need to log in
How to make a proper redirect from http to https?
Good afternoon!
I recently connected an SSL certificate to a WordPress site https://suvorovski.ru At the moment, the site is available via both http and https protocols. I want to make a 301 redirect from http to https through the .htaccess file in the root of the site for all pages of the site.
I thought that the task was simple, but I got confused in the end. Here, I ask for help.
Right now my .htaccess file looks like this:
# BEGIN WordPress
<Files wp-login.php>
Order Deny,Allow
Deny from all
</Files>
<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
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
Answer the question
In order to leave comments, you need to log in
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
to the very beginning
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question