Updating URLs in WordPress (Firstserv Guide)
When changing your website’s domain name or moving from a staging environment to a live site, it’s essential to update all URLs. This ensures that links, images, and other resources point to the correct location and your website functions properly.
Below are two common methods: using a plugin (recommended) or using WP-CLI via SSH.
Option 1: Using a Plugin (Recommended for Most Users)
Step 1: Install the Plugin
- Log in to your WordPress dashboard
- Go to Plugins → Add New
- Search for “Better Search Replace”
- Click Install Now, then Activate
Step 2: Run a Search and Replace
- Navigate to Tools → Better Search Replace
- Enter:
- Search for: your old URL (e.g.
staging.yoursite.com) - Replace with: your new URL (e.g.
yoursite.com)
- Search for: your old URL (e.g.
- Select the relevant database tables (typically all tables)
Step 3: Perform a Test Run
- Enable the Dry Run option
- Run the tool to preview how many changes will be made (no changes applied yet)
Step 4: Apply Changes
- If the results look correct:
- Disable Dry Run
- Click Run Search/Replace
Step 5: Clear Cache
After completing the update:
- Clear your caching plugin (e.g. LiteSpeed Cache)
- Clear any browser or CDN cache
✅ This ensures your updates take effect immediately.
Option 2: Using WP-CLI (Advanced Users)
If your hosting includes SSH access, you can use WP-CLI for a faster, command-line approach.
Step 1: Access Terminal
- Log in to cPanel
- Open Terminal (under the Advanced section)
- Launch the terminal environment
Step 2: Navigate to Your WordPress Directory
(Adjust this path if your WordPress installation is in a different directory.)
Step 3: Preview Changes (Recommended)
Run a dry run to see what will be updated:
Step 4: Apply Changes
Once you’re satisfied with the preview:
Step 5: Clear Cache
- Clear any WordPress caching plugins
- Flush server or CDN cache if applicable
Important Tips
- ✅ Always back up your database before making bulk changes
- ✅ Ensure consistency (update
http://tohttps://if needed) - ✅ Test your website thoroughly after making changes
Summary
Updating URLs is a key step when migrating or renaming your WordPress site. You can:
- Use a plugin for a simple, user-friendly approach
- Use WP-CLI for a faster, more advanced method
If you need assistance updating your URLs or migrating your website, the Firstserv support team is always available to help.
