Changing Domains and Migrating Sites with WP Rocket
When you change the domain for your site, enable HTTPS, change the primary version of your domain from www to non-www (or vice versa) or move a site from a development URL to a live URL, the WP Rocket configuration must be updated to match.
In this article:
Deactivate and reactivate WP Rocket
Deactivate and reactivate WP Rocket in its new location, or after making any changes to your domain, so that the configuration file can be updated correctly.
This should be all that is required. If you have any problems, you should manually check and clean up the following files and folders.
Remove old files
There should only be 1 PHP file here (except for multilingual sites), named with your site’s domain(s), for example:
This is the WP Rocket configuration file and it's required for the correct functioning of the plugin. If you see another file in this folder with the domain name of the old site, or development site, just delete it.
⚠️ The filename must match your domain as it appears in WordPress Settings → General. If the domain in the WordPress settings contains www, the PHP file should also contain it, and in that case if there is a version of the file without www, that one should be deleted.
If your domain does not use www, the WP Rocket config file should not have it either.
If this case,
www.example.org.php should be kept and
There should be a folder named with your site's domain here. For example:
If you've duplicated the website from your development site, you might have a folder named like your dev site, or the previous domain your site used. You can delete that old folder.
www matters here as well. The folder name should match the domain as it appears in your WordPress settings, with or without the
www. If both exist, remove the one that does not match your settings.
When you re-activate WP Rocket, the plugin should automatically create or update this file, but you can double-check it to make sure it has the correct paths in it.
If think it might be incorrect, or if you're not sure, you can delete the file. Then de-activate and re-activate WP Rocket, so the file will be regenerated.
Ensure redirects are in place
If you have changed from HTTP to HTTPS or between the WWW and non-WWW version of the domain, you will also need to ensure the correct redirects are in place. Speak to your webhost about that, or you can use these helper plugins:
Migrating your site
If you are moving your site from one location to another, you should exclude the content of the /wp-content/cache/ folder from the migration process.
Using Export / Import Settings tools and a fresh copy of WP Rocket
An alternate method is to reinstall WP Rocket:
- On Site A, go to Settings > WP Rocket > Tools
- Export your current WP Rocket settings
- Download your new WP Rocket zip file from https://wp-rocket.me/account
- Install and activate the new WP Rocket zip file on Site B
- Import Site A settings on the Tools tab of Site B
Make sure your site is already using WP Rocket version 3.x in order to use the settings export/import. Older versions used a different export file format, which is not compatible with the newer versions.
More details on Export / Import Settings here: Tools Tab: Export/ Import Settings and Version Rollback
Pushing changes from Staging to Production
WP Rocket will automatically regenerate the
advanced-cache.php file when the plugin detects that the paths inside it are no longer correct.
The reason is that WP Rocket is adding server-specific paths in the
advanced-cache.php file. When you push that file to another server, where the paths are different, WP Rocket won't work. Deactivating/reactivating WP Rocket fixes the issue because the
advanced-cache.php is recreated.
The solution here is to not push the
advanced-cache.php file by adding it to
That way, each server will have their own version of the file with the correct paths.
WP CLI user?
You can use our WP Rocket CLI to re-generate the necessary files. Please see: https://github.com/GeekPress/wp-rocket-cli, and specifically the
wp rocket regenerate command.