after an analysis of the woorank site, i have this result
So i try to add a 301 redirection for https://monsite.com to https://www.monsite.com
301 https redirects to without WWW
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But it’s doesnt work. For information, i use the default htaccess
# BEGIN WordPress
# Les directives (lignes) entre « BEGIN WordPress » et « END WordPress » sont générées
# dynamiquement, et doivent être modifiées uniquement via les filtres WordPress.
# Toute modification des directives situées entre ces marqueurs sera surchargée.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thnaks in advance
2
Answers
This rule is only redirecting to
https
site, not addingwww
. You can use this rule to do both redirections in a single rule:Once you verify it is working fine, replace
R=302
toR=301
. Avoid usingR=301
(Permanent Redirect) while testing yourmod_rewrite
rules.Your full .htaccess
I have often found that plugins handle this better than trying to do it manually with the .htaccess file, so you could try that as an alternative.
Here are some options in this article:
https://cheapsslsecurity.com/p/best-http-to-https-wordpress-plugins/