Page 1 of 1

How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Mon Jun 07, 2021 9:51 pm
by XerxeS
hi all
i have a simple issue. :D

eg. i have a site https://site-blah.com where letsencrypt works fine (SSL is active)
however on https://site-blah.com/subfolder/ letsencrypt does not work (SSL not active)
within the subfolder wordpress is intalled.
how do i get letsencrypt to provide SSL for a subfolder ?

thanks
XerxeS

v-migrate-site-to-https

Posted: Tue Jun 08, 2021 2:08 pm
by myVesta
SSL is active for sure, but your wordpress has 'http://' URL in it's database (instead of 'https://').
We have command v-migrate-site-to-https:
You can call it from SSH:

Code: Select all

sudo /usr/local/vesta/bin/v-migrate-site-to-https yourdomain.com
and it will automatically replace http://yourdomain.com to https://yourdomain.com in your WordPress database.

That's it !

---------------------------

...but, if your WordPress is uploaded in subfolder, our script will not detect WordPress in subfolder.

However, you can do http to https replace manually, with wp-cli:

Code: Select all

sudo wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
sudo chmod +x /usr/local/bin/wp

USER='' # enter here hosting username
DOMAIN='' # enter here domain, without http://, https:// and without www.
alias php='php7.3' # change to desired php version

cd /home/$USER/web/$DOMAIN/public_html/

sudo -H -u$USER wp search-replace "http://$DOMAIN" "https://$DOMAIN" --precise --all-tables --skip-columns=guid
sudo -H -u$USER wp search-replace "http://www.$DOMAIN" "https://www.$DOMAIN" --precise --all-tables --skip-columns=guid
sudo -H -u$USER wp cache flush
service memcached restart

grep -rl "http://$DOMAIN" ./ | xargs sed -i "s#http://$DOMAIN#https://$DOMAIN#g"
grep -rl "http://www.$DOMAIN" ./ | xargs sed -i "s#http://www.$DOMAIN#https://www.$DOMAIN#g"

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Mon Nov 22, 2021 3:29 pm
by crafter
What is the code for redirecting to https for other non wordpress site? i want to redirect for the entire hostdomain.

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Mon Nov 22, 2021 3:55 pm
by myVesta
crafter wrote:
Mon Nov 22, 2021 3:29 pm
What is the code for redirecting to https for other non wordpress site? i want to redirect for the entire hostdomain.
try https://interconnectit.com/search-and-r ... databases/
replace "http://yourdomain" to "https://yourdomain"
then put "force-https" nginx template in myVesta

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Mon Nov 22, 2021 8:11 pm
by crafter
i have put nginx to force https yet it did not work and i do not understand which package you refer to in the link you provided or the steps to take to use the many information on the page

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Mon Nov 22, 2021 8:18 pm
by myVesta
crafter wrote:
Mon Nov 22, 2021 8:11 pm
i have put nginx to force https yet it did not work and i do not understand which package you refer to in the link you provided or the steps to take to use the many information on the page
https://interconnectit.com/search-and-r ... databases/

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Tue Nov 23, 2021 9:18 am
by crafter
Thanks for the link but I want to redirect http to https on my hostname not move database. I have ssl installed already. i need code to redirect http to https on server through ssh.

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Tue Nov 23, 2021 10:43 am
by myVesta
in your public_html/ folder add this to .htaccess file:

Code: Select all

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Re: How to migrate WordPress to https (v-migrate-site-to-https)

Posted: Tue Nov 23, 2021 12:11 pm
by crafter
This is the top content of my .htaccess file. Should i edit out the current rewrite rule completely and replace with the one you provided or where exactly should i place the new rule? thanks


###########################################################################
# Désactive l'encodage par défaut et définit la priorité des langues
AddDefaultCharset Off

###########################################################################
# Réécriture d'url
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [NC,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

###########################################################################
# PHP_AUTH_BASIC
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

###########################################################################
# Compression
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE