Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Homepage with many 301 redirects

         

jediviper

2:10 pm on Nov 2, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



At a new wordpress website, I have noticed that when putting the domain.com at a browser, we get these 2 redirects:
[imgur.com...]
The second redirect is because of the Polylang plugin.

If we try the domain as www.domain.com then we get a 302 redirect to the https www domain.com en home version.

How can we fix these 2 issues?
From the first type, to remove one of the 2 redirects.
From the second type, to replace the 302 with a 301 redirect.

jediviper

7:41 am on Nov 6, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



@phranque
Unfortunately the situation hasn't been improved.
Again I have 2 301 redirects according to [httpstatus.io...] when I type the domain.com version. It always jumps from http to https and then to https-www.

I did remove the previous part and added your part:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !(^www\.example\.com$)? [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]


Also, I kept the part:
# HTTPS forced by SG-Optimizer
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]
</IfModule>
# END HTTPS

phranque

8:42 am on Nov 6, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Also, I kept the part:

try removing this since i specifically recommended you do so and then tell me if my recommendation worked.

jediviper

9:03 am on Nov 6, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hmm the domain com works with 1 redirect.

But the www version has also 1 redirect.

[edited by: jediviper at 9:20 am (utc) on Nov 6, 2020]

phranque

9:13 am on Nov 6, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



.htaccess is an apache web server concept.
the SSL handshake (i.e., the secure connection) occurs before the web connection.

the rewrite directives i suggested include a 301 redirect to the secure protocol when http: is requested.
it is only after the subsequent request is made that SSL gets involved.

jediviper

11:53 am on Nov 6, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



I have removed the other part and kept only your part and now there is a 301 redirect in both cases.
Is this how it was supposed to be?

phranque

2:35 am on Nov 7, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



now there is a 301 redirect in both cases.
Is this how it was supposed to be?

all non-canonical requests should redirect in a single 301 to the canonical.

phranque

3:29 am on Nov 7, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



what do you mean by "both cases"?

these are 4 cases:
https://www.example.com/
http://www.example.com/
https://example.com/
http://example.com/

if https://www.example.com/ is the canonical home page then requests for the other 3 cases should 301 redirect in a single hop to https://www.example.com/

jediviper

1:51 pm on Nov 9, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



Yes you are right. So according to that it makes sense to have the 301 redirect.
So if I decide soon to implement again the Polylang plugin. Will this bring just the insertion of the /en/ in the url structure without any new redirects?
This 38 message thread spans 2 pages: 38