- restore database and files.
- change php.ini (increase upload_max_filesize and post_max_size values if needed).
- change wp-config.php (database name, userid, and password).
- change domain name entries in SQL table wp-options (siteurl and home entries).
- Install and activate the Better Search Replace plugin if not yet done so.
- run the Better Search Replace plugin (dashboard->Tools)
- Choose tables wp-posts and wp-postmeta.
- replace ‘https://testsite.songchanhniem.com‘ with ‘http://localhost/scn-test‘
- replace ‘http://testsite.songchanhniem.com‘ with ‘http://localhost/scn-test‘
- run Elementor’s URL Replace tool (elementor->tools->URL Replace
- replace ‘https://testsite.songchanhniem.com‘ with ‘http://localhost/scn-test‘
- replace ‘http://testsite.songchanhniem.com‘ with ‘http://localhost/scn-test‘
- Deactivate the Better Replace Search plugin once migration is completed.
NOTE: Do not need to run Regenerate CSS because running it seems to make Elementor’s global custom colors disappeared.
Clone MySQL Database
- From phpmyadmin, make sure that the destination database is empty.
- Export source source database (let’s call it mybackup.sql).
- from cPanel, upload mybackup.sql to any folder (ie /tmp).
- from cPanel, open Terminal, change to /tmp folder.
- execute: mysql -u db-username -p database-name <mybackup.sql
provide password when prompted. - Go to phpmyadmin and verify the newly imported content.
Setup WP site in a subfolder
WP site = songchanhniem.com
subfolder = /scnprod
- Domain songchanhniem.com still points to root public_html.
- Add the following code to /public_html/.htaccess file:
- # Minh – redirect WordPress main site to subdirectory /scnprod
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?songchanhniem.com$
RewriteCond %{REQUEST_URI} !^/scnprod/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /scnprod/$1
RewriteCond %{HTTP_HOST} ^(www.)?songchanhniem.com$
RewriteRule ^(/)?$ scnprod/index.php [L]
</IfModule>
# END WordPress
- # Minh – redirect WordPress main site to subdirectory /scnprod
- This is the content of the .htaccess in the subfolder /public_html/scnprod/.htaccess:
- <IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
- <IfModule mod_rewrite.c>