Last active
February 13, 2017 06:58
-
-
Save hemraj7171/1a81fbfeb202a009ba5abd64fe9fdc80 to your computer and use it in GitHub Desktop.
HTTP to HTTPS WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Install SSL licence into your domain | |
2. Run following migration query: | |
UPDATE wp_options SET option_value = replace(option_value, 'http://www.site.com', 'https://www.site.com') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, 'http://www.site.com','https://www.site.com'); | |
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.site.com', 'https://www.site.com'); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.site.com', 'https://www.site.com'); | |
NOTE: please change the site with your domain and also change the table prefix if required | |
3. Add redirection rule on .htaccess file: | |
# Redirect HTTP to HTTPS | |
RewriteEngine On | |
RewriteCond %{HTTPS} !on | |
RewriteCond %{SERVER_PORT} !^443$ | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] | |
4. Additionally, you can enable force admin login | |
define( 'FORCE_SSL_LOGIN', TRUE ); | |
define('FORCE_SSL_ADMIN', true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment