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.

Admin notice

When WP Rocket detects the domain was changed, the following admin notice with a button called "Regenerate WP Rocket configuration files now" will be displayed:

WP Rocket: We detected that the website domain has changed. The configuration files must be regenerated for the page cache and all other optimizations to work as intended. Learn more.

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, should be kept and removed.


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:

  1. On Site A, go to Settings > WP Rocket > Tools
  2. Export your current WP Rocket settings
  3. Download your new WP Rocket zip file from
  4. Install and activate the new WP Rocket zip file on Site B
  5. 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.

Additionally, if needed, WP Rocket will regenerate its PHP configuration file, located inside /wp-content/wp-rocket-config/ to match the current domain name, for example,

⚠️ However, this regeneration of config files happens only after there is admin access to the WP Admin area.

The solution here is to:

1) Prepare your GitHub repository beforehand:

  • Not push the advanced-cache.php file by adding it to .gitignore.
  • If WP Rocket is active and running in production and in staging, avoid overriding the contents of the /wp-content/wp-rocket-config/ folder by adding it to .gitignore. Or at least, prevent WP Rocket's PHP config file ( from being overridden/deleted

2) After pushing to production:

  • If you made any changes to WP Rocket settings in staging, login to WP Admin in Production, to regenerate the config files in case is needed.
  • Deactivate / Reactivate WP Rocket.

That way, each server will have its own version of the files with the correct names and paths.

WP CLI user?
You can use our WP Rocket CLI to re-generate the necessary files. Please see:, and specifically the wp rocket regenerate command.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.