WordPress站点迁移后插件失效及前后端JavaScript报错求助
Hey there, let's walk through fixing this frustrating issue you're dealing with—plugin failures, backend errors, and broken jQuery after moving your site to a new domain. Even if you've updated URLs already, there are a few common culprits we can check step by step:
1. Hunt Down Residual Old URLs in the Database
It's easy to miss hidden old URLs scattered across your database (not just the wp_options table's siteurl and home values). Here's how to clean them up:
- Backup first: Always make a full database backup before making changes—you don't want to make things worse!
- Use WP CLI (if you have access): Run this command to replace every instance of your old domain with the new one across all tables:
Make sure to match the protocol (http/https) exactly for both old and new URLs.wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables - If you don't have WP CLI: Use phpMyAdmin to run a search-and-replace across all tables. Look for tools like the "Search and Replace" feature in phpMyAdmin, or upload the Better Search Replace plugin via FTP (if you can't access the plugin installer) to handle the cleanup.
2. Wipe All Caches (Everywhere!)
Cached old URLs are one of the most common reasons for post-migration issues. Clear:
- WordPress caching plugins: If you can access the backend, flush the cache there. If not, delete the
wp-content/cachefolder via FTP. - Server/CDN cache: Check your hosting provider's dashboard to flush server-level cache (like Redis, Memcached) or any CDN you're using (e.g., Cloudflare).
- Browser cache: Hard-refresh your browser with
Ctrl+Shift+R(Windows) orCmd+Shift+R(Mac) to bypass local cached files.
3. Disable Plugins to Rule Out Conflicts
Even if all plugins seem broken, a single plugin with hardcoded old URLs might be causing a chain reaction:
- Rename plugins folder: Via FTP, go to
wp-content/and rename thepluginsfolder toplugins-old. This disables all plugins at once. - Test if the site works: Check if the backend errors are gone and jQuery loads properly. If yes, rename the folder back to
pluginsand enable plugins one by one, testing after each to find the problematic one. - Fix the culprit plugin: For the problematic plugin, search its database entries for old URLs or check its settings files for hardcoded paths that need updating.
4. Verify wp-config.php & .htaccess Settings
- Check wp-config.php: Add or update these lines to force the new domain (replace with your actual URL):
This overrides the database values and ensures WordPress uses the correct domain.define('WP_HOME', 'https://new-domain.com'); define('WP_SITEURL', 'https://new-domain.com'); - Reset .htaccess: Backup your existing
.htaccessfile, delete it, then go to your WordPress backend (Settings → Permalinks) and click "Save Changes". WordPress will generate a fresh.htaccessfile with the correct rewrite rules for your new domain.
5. Fix jQuery Loading Failures
If jQuery is broken, open your browser's developer tools (F12 → Console) and look for 404 errors. These will show you which files are trying to load from the old domain:
- If the error points to a jQuery file with the old URL: Go back to step 1—you missed a database entry or a hardcoded path.
- Check your theme files: Some themes hardcode jQuery or asset paths in
functions.php,header.php, orfooter.php. Search these files for your old domain and replace it with the new one.
6. Check File Permissions
Migration can sometimes mess up file permissions, preventing WordPress from accessing plugin files:
- Set
wp-content/pluginsfolder permissions to755(read/write/execute for owner, read/execute for group and others). - Set individual plugin files to
644(read/write for owner, read for others). - You can adjust permissions via FTP or your hosting provider's file manager.
Take it slow, test after each step, and remember to backup everything before making changes—you've got this!
内容的提问来源于stack exchange,提问作者Aleks Pvn

