0

I have installed an SSL Certificate on my hosting, for my wordpress site.

How can I redirect my old 'http' URL to my new 'https' URL, through the use of the .htaccess file, with minimum effect on my SEO Rankings?

  • Possible duplicate of [How to redirect all HTTP requests to HTTPS](https://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https) – Elvin Haci Nov 25 '17 at 19:12

1 Answers1

0

The first option is to configure your website to work via HTTPS instead of HTTP. By default, WordPress is redirecting all of other links to the default protocol(in your case HTTPS).

You can configure it via WP-Cli. The command you need is:

wp search-replace 'OLD-URL' 'NEW-URL' --precise --recurse-objects --all-tables-with-prefix

You may check the following tutorial for more information: https://developer.wordpress.org/cli/commands/search-replace/

Another option is to set the 301 redirects in the .htaccess. I am using the following code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

Additional information on these types of moves from Google can be found at: https://support.google.com/webmasters/answer/6033049?hl=en&ref_topic=6033084

sokeefe
  • 627
  • 12
  • 33
Vasil
  • 41
  • 3