How to move wordpress site to new directory

Moving a WordPress site to a new directory can be a bit tricky, but it's a relatively straightforward process. Here's a step-by-step guide to help you do it:

Before you start:

  1. Backup your site: Before making any changes, make sure to backup your WordPress site, including the database and files.
  2. Update your site's URL: In your WordPress dashboard, go to Settings > General and update the Site Address (URL) to the new directory. This will ensure that your site's internal links are updated correctly.

Step 1: Move the files

  1. Create a new directory: Create a new directory on your server where you want to move your WordPress site. For example, /newdirectory.

  2. Copy the files: Copy all the files from your current WordPress directory to the new directory. You can use an FTP client like FileZilla or a file manager like cPanel to do this.

  3. Update the file paths: Update the file paths in your WordPress configuration file (wp-config.php) to point to the new directory. Look for the following lines and update them accordingly:

    define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT']. '/newdirectory/wp-content');
    define('WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT']. '/newdirectory/wp-content/plugins');

    Step 2: Update the database

  4. Export the database: Export your WordPress database using phpMyAdmin or a similar tool. This will create a SQL file that contains the database structure and data.

  5. Update the database prefix: Update the database prefix in the SQL file to match the new directory structure. For example, if your old prefix was wp_, you might update it to newdirectory_wp_.

  6. Import the database: Import the updated SQL file into your new database.

Step 3: Update the WordPress configuration

  1. Update the wp-config.php file: Update the wp-config.php file to point to the new database and directory structure. Look for the following lines and update them accordingly:

    define('DB_NAME', 'newdatabase');
    define('DB_USER', 'newusername');
    define('DB_PASSWORD', 'newpassword');
    define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT']. '/newdirectory/wp-content');
    define('WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT']. '/newdirectory/wp-content/plugins');

    Step 4: Update the site's URL

  2. Update the site's URL: In your WordPress dashboard, go to Settings > General and update the Site Address (URL) to the new directory.

Step 5: Test your site

  1. Test your site: Visit your site in a web browser to ensure that everything is working correctly. Check that all pages, posts, and plugins are functioning as expected.

That's it! With these steps, you should be able to move your WordPress site to a new directory. If you encounter any issues, feel free to ask for help.