Hello guys i’m new and I have question. I have one website that have indexed https and http version in google search, and I added 301 redirect from HTTPS to HTTP in .htaccess. Sometimes, Randomly, 301 redirect disappeared from htaccess and I need to add it again.
This is my htaccess with 301 redirect:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And After some times, they change to this
# 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
So the redirect was completely removed, google index again https page and I need to add it again, why? I tried many hosting company but nothing changed.
2
Answers
Thanks @janh, so this is correct?
I would not redirect vom HTTPS to HTTP, but the other way round. Google will give you a small ranking boost if you are using HTTPS (not to speak of it being the right thing to do to protect your users’ privacy).
That being said: don’t put anything between the WordPress markers, e.g.
WordPress will overwrite it the next time it writes to the .htaccess.
If you put it before that block, i.e.
You should be fine, and it should remain intact.