Welcome to Help center

We are here to help

How to move from http to https

Follow

Secured https-protocol is activated by installing an SSL certificate on a server. Depending on SSL certificate type the certificate authority will verify your domain and provide you with your SSL certificate

After you install an SSL certificate each http page is required to be configured to its corresponding https page. This procedure means transfer of the site to another domain. Redirect should be straight and not to include the intermediate documents, otherwise a chain of redirects will be formed. They confuse search engines and have a negative impact on the perception of the whole site.

 

https settings in WordPress

The main site protocol from http to https can be changed in the WordPress admin panel Settings → General.

 

301 redirect http to https WordPress via php-code

Open the functions.php file and write the following code:

 

function force_https () {
if ( !is_ssl() ) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action ( 'template_redirect', 'force_https', 1 );

 

Site interlinking

Alternatively, you can perform a redirect from http to https using .htaccess

1.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>

2.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]
</IfModule>

 

Have more questions?

Submit a request

Comments

Top
Powered by Zendesk