Tutorial-Deploying WordPress website from localhost to a subfolder on Existing WordPress Domain

This is a tutorial for all those who want their WordPress(WP) website present on localhost to be running on folder created on the server.

Status before deploying WordPress:

  • I have a working wordpress website on the  localhost.

  • I want to run another WP in the subfolder(eg. https://www.cinnamonteal.in/thedogearsbookshop ) on the main existing WP website(eg. https://www.cinnamonteal.in)


  • Change the table-prefix everywhere in the local mysql database and then make sure all instances of the table-prefix are replaced. (Note: Change the default table-prefix from wp_ because this improves security and this prevents tablename conflict if there is a WP website installed on the server with default table-prefix.)

  • Then change the table-prefix in wp-config.php on the localhost .

  • Then export the local mysql database.

  • After importing table from local d/b to live d/b (eg. wpdogdb to cinnamonteal database), execute the following sql queries:

UPDATE db_options SET option_value = replace(option_value, ‘ http://localhost/TheDogearsetcBookshop/wordpress2’,                  ‘http://www.cinnamonteal.in/thedogearsbookshop’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

UPDATE db_posts SET guid = replace(guid, ‘http://localhost/TheDogearsetcBookshop/wordpress2’, ‘http://www.cinnamonteal.in/thedogearsbookshop‘);

UPDATE db_posts SET post_content = replace(post_content,’http://localhost/TheDogearsetcBookshop/wordpress2′, ‘http://www.cinnamonteal.in/thedogearsbookshop‘);

UPDATE db_postmeta SET meta_value = replace(meta_value,’http://localhost/TheDogearsetcBookshop/wordpress2′, ‘           http://www.cinnamonteal.in/thedogearsbookshop‘);

  • Then after a successful import of database create a folder on the server (eg. thedogearsbookshop)

    Files on the server

  • Copy all the localhost wordpress files(eg. /thedogearsetcbookshop/wordpress2/)and then paste them into the folder created on the server (eg. Thedogearsbookshop/ ).

    Wordpress files_localhost



  • Get the user credentials of database such as mysql databasename, mysql username , mysql password , mysql hostname.

           The wp-config.php for my folder looked like

             /** The name of the database for WordPress */

             define(‘DB_NAME’, ‘cinamonteal-in’);

             /** MySQL database username */

             define(‘DB_USER’, ‘cinamonteal-in’);

             /** MySQL database password */

             define(‘DB_PASSWORD’, ‘*****************’); /* hid password for Blog purpose*/

             /** MySQL hostname */

             define(‘DB_HOST’, ‘cinamontealin.mysql’);

             /** Database Charset to use in creating database tables. */

             define(‘DB_CHARSET’, ‘utf8’);

             /** The Database Collate type. Don’t change this if in doubt. */

             define(‘DB_COLLATE’, ”);

  • Open the index.php in the subdirectory present on the server and  then make sure it says

             require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );

  • Open the .htaccess(usually hidden) in the subdirectory present on the server and then make sure it says

    # BEGIN WordPress

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteBase /thedogearsbookshop/

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /thedogearsbookshop/index.php [L]


    # END WordPress

    Replace “thedogearsbookshop” with the folder name created on server.

  • Before entering the website, login as an admin

    eg https://www.cinnamonteal.in/thedogearsbookshop/wp-admin/

  • Then login using your credentials present on the localhost.

  • Then deactivate all the plugins and set the theme to default if possible .

  • Thats it, now enter the following the web browser

    eg cinnamonteal.in/thedogearsbookshop

  • If it displays website, try enabling desired theme first and then gradually activate plugins one by one.

Note: Create a safe backup of the files and database present on the live server and then proceed with the above steps.

After deploying the WordPress, you can get started by exploring our WordPress Guide : 7 Best Practices