You installed your WordPress in a subfolder (e.g. http://domain.com/sub-folder) and you want to move it to the main folder (e.g. http://domain.com )? That is no problem! With few steps, you can do it. Here is a step by step guideline for you:
- First move/copy the contents of “sub-folder” to the root document i.e under public_html folder of your domain, you can use the FTP, SSH or ‘move’ option within the Servage file manager to serve this purpose.
- Check the database details you are using for the blog. You can find the database details in the file wp-config.php.
- Make a backup copy of the database before making the changes.https://helpdesk.servage.net/938961–How-to-export-a-database-dump-SSH
- Once the database is backed up, Go to the phpmyadmin of the database and run these sql queries from the database:
- UPDATE wp_options SET option_value = replace(option_value, ‘http://domain.com/sub-folder‘, ‘http://domain.com‘) WHERE option_name = ‘home’ OR option_name = ‘siteurl';
- UPDATE wp_posts SET guid = replace(guid, ‘http://domain.com/sub-folder’,’http://domain.com‘);
- UPDATE wp_posts SET post_content = replace(post_content, ‘http://domain.com/sub-folder‘, ‘http://domain.com‘);
- UPDATE wp_options SET option_value = replace(option_value, ‘http://domain.com/sub-folder‘, ‘http://domain.com‘);
- The above queries will do the trick on most of the occasions and would be enough. Possibly on rare oaccasions, we may need to run more queries as well to change the instance from http://domain.com/sub-folder to http://domain.com in the database.
- Replace ‘http://domain.com/sub-folder and http://domain.com with the domain name subfolder and domain names.
You’re done !
Ensure that the Rewrite code under .htaccess file is as below for wordpress:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Usually since the blog is installed under sub-folder, the rewrite code you will see as
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . sub-folder/index.php [L]
</IfModule>
# END WordPress
Since we have moved to root folder, so no need of ‘sub-folder’ now.
Important Note : Please make a local backup at your end before making these changes for security reasons for both files and databases.
No comments yet (leave a comment)