I have web page created in WordPress v5.4, Theme Twenty Twelve and just installed SSL certificate.
I want to have such redirection structure (redirection codes in rectangles), to optimize for SEO:
but according to Google Chrome Site Inspector I have the follwing one:
So the schema is not fully optimized as for two cases there are dwo cascade redirections whereas should be one.
What is weird, current schema doesn’t reflect .htaccess file. My .htaccess file looks as follows:
# 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
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
So, my understanding of the code is that if url is typed in without https://, script rewrites it into version with https:// an nothing else, so there must be another place where other redirections (e.g. with www -> without www) are being made.
I have checked index.php – no redirections.
I also checked additional lines in .htaccess file don’t overwrite those “hidden” ones, so if I simply add them I got multiple redirections error in web browser.
Could you please advise me what else should I do to get desired structure of redirections?
2
Answers
I’m guessing the redirect from www to non-www is due to the address you’ve set in your settings (WordPress dashboard → Settings → General).
For the redirect you want to achieve, you have to add rewrite conditions for the
www.
in your.htaccess
First rule redirect all www to https://domainname.com/, second all http to https://domainname.com/, one hop