I just moved my wordpress site to HTTPS on the same server as before, and everything is working right. I set up a redirect 301 rule and got it working, however when checking the "flow" of traffic I noticed that from http://www.domain
to https://domain
I have at least two redirects instead of only one. This do not happen from http://domain
or https://www.domain
to the same https://domain
page.
The rule I'm using is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I used this link to test redirects count
My fear is to lose speed and/or rankings of google. Any advice is appreciated.
You can set your site url and wp-content (home) url constants in wp-config.php like so:
define('WP_SITEURL', 'https://example.com');
define('WP_HOME', 'https://example.com');
(Make sure there are no dupicates of this rule and to add it before the 'stop editing, happy blogging' note in the file. Also, backup your old file before changing it.)
I would then suggest to separate your .htaccess rules as your current setup may not survive an update because you've removed the # END WordPress statement, which is required by the WP core if pretty permalinks have been enabled.
#REDIRECT TO HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</IfModule>
and directly below that goes standard WordPress part:
# 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
This is how I've setup many websites and it always works fine, some servers do like them in a different order but it is recommended to first go to https and then serve the WP files, ideally your webserver would be set to only serve your site via https, which would effectively eliminate the need of this workaround: