Changing the domain name of your WordPress site involves several steps to ensure a smooth transition. Here’s a comprehensive guide to help you through the process:
1. Backup Your Website:
- Before making any changes, create a complete backup of your WordPress site, including files and the database. This precaution ensures you can restore your site if anything goes wrong.
2. Update Domain Settings in WordPress:
- Access WordPress Dashboard: Log in to your WordPress admin panel.
- Navigate to Settings: Go to Settings > General.
- Modify URLs: Update the following fields with your new domain name:
- WordPress Address (URL): Enter https://yournewdomain.com.
- Site Address (URL): Enter https://yournewdomain.com.
- Save Changes: Click Save Changes to apply the new settings.
3. Update the wp-config.php File:
- Access File Manager: Use your hosting control panel’s File Manager or an FTP client to locate the wp-config.php file in your site’s root directory.
- Edit the File: Add the following lines before the line that says “That’s all, stop editing! Happy blogging.”:
php
Copy
define(‘WP_HOME’, ‘https://yournewdomain.com’);
define(‘WP_SITEURL’, ‘https://yournewdomain.com’);
- Save Changes: Save the file to apply the new domain settings.
4. Update the Database:
- Access phpMyAdmin: Log in to your hosting control panel and open phpMyAdmin.
- Select Database: Choose the database associated with your WordPress site.
- Update URLs:
- Navigate to the wp_options table.
- Locate the siteurl and home rows.
- Click Edit and replace the old domain with your new domain.
- Save the changes.
5. Update Internal Links and Media:
- Use a Search and Replace Plugin: Install and activate a plugin like “Better Search Replace” to update internal links and media URLs in your database.
- Configure the Plugin: Set it to search for your old domain and replace it with the new one across all tables.
- Run the Replacement: Execute the replacement process and verify that all links and media are correctly updated.
6. Set Up 301 Redirects:
- Create Redirects: To preserve SEO rankings and ensure visitors are directed to the new domain, set up 301 redirects from the old domain to the new one.
- Modify .htaccess File: Add the following lines to your .htaccess file in the root directory:
apache
Copy
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?yourolddomain\.com$ [NC]
RewriteRule ^(.*)$ https://yournewdomain.com/$1 [L,R=301]
- Save Changes: Save the .htaccess file to implement the redirects.
7. Update Domain in Hosting Control Panel:
- Access Hosting Settings: Log in to your hosting control panel.
- Change Domain: Navigate to the domain management section and update the domain name to your new domain.
- Verify Changes: Ensure that the hosting settings reflect the new domain.
8. Test Your Website:
- Check Functionality: Visit your new domain to ensure the website loads correctly and all links function as expected.
- Verify Redirects: Test the 301 redirects by entering the old domain in the browser and confirming it redirects to the new domain.
9. Update External Links and Services:
- Notify Search Engines: Update your domain information in Google Search Console and other webmaster tools.
- Update social media and Directories: Change your domain on social media profiles, business directories, and other platforms where your old domain is listed.
Additional Considerations:
- SSL Certificate: Ensure your new domain has an SSL certificate installed to maintain secure connections.
- Email Accounts: If you use email addresses associated with your old domain, set up new email accounts for the new domain and configure email forwarding if necessary.