WordPress迁移后后台无法访问(500错误)及文件修改不生效求助
Alright, let's break down how to fix these interconnected issues you're facing after migrating your WordPress site—500 errors on the admin, file changes not sticking via webFTP, and being stuck with the All in One WP Security (AIOS) plugin you can't disable normally. Here's a step-by-step approach:
First, Fix the "File Changes Not Taking Effect" Problem
If your edits via webFTP aren't showing up, none of the other fixes will work. This is almost always a cache or file permissions issue:
- Check server/CDN cache: Many hosts enable OPcache, or you might have Cloudflare/another CDN running. Try clearing your host's server cache (look for an option in your hosting panel), or temporarily pause CDN services. Even adding a random comment to a file (like
wp-config.php) can force a cache refresh. - Verify file permissions: If the web server doesn't own the files, your webFTP edits might be modifying a different version (or the server is loading cached copies). Use webFTP to check permissions: set directories like
wp-contentandwp-adminto755, and files to644. If that doesn't work, temporarily set the file you need to edit to777(change it back immediately after—it's insecure!) to see if your edits stick.
Bypass the AIOS Plugin to Fix the 500 Error
Since AIOS is the likely culprit and you can't disable it via the admin, force-disable it through file edits:
- Rename the plugin directory: Navigate to
wp-content/plugins/and rename theall-in-one-wp-security-and-firewallfolder to something likeall-in-one-wp-security-and-firewall-disabled. WordPress will automatically deactivate any plugin whose directory doesn't match its registered name. If renaming doesn't work first, go back and fix the file change issue above. - Temporarily disable all plugins via wp-config.php: If renaming the AIOS directory fails, add these lines to your
wp-config.phpright before the/* That's all, stop editing! Happy publishing. */line:
This tricks WordPress into looking for plugins in a non-existent folder, disabling all of them. Once you can access the admin, revert this line and deactivate AIOS properly.define('PLUGINS_DIR', './wp-content/plugins-disabled'); - Remove AIOS .htaccess rules: AIOS often adds custom security rules to your
.htaccessfile. Open.htaccessand delete the block wrapped in# BEGIN All In One WP Securityand# END All In One WP Security. Save the file—if the 500 error goes away, these rules were incompatible with your new server (e.g., if you moved from Apache to Nginx).
Troubleshoot the 500 Error If AIOS Isn't the Issue
If disabling AIOS doesn't fix the 500 error, dig into the root cause:
- Enable WordPress debug logging: Add these lines to
wp-config.phpto log errors to a file:
You can then downloaddefine('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);wp-content/debug.logvia webFTP to see exactly what's causing the error (e.g., missing functions, memory limits, database connection issues). - Increase PHP memory limit: Migration can sometimes reset your PHP memory limit. Add this to
wp-config.php:define('WP_MEMORY_LIMIT', '256M'); - Verify database credentials: Double-check that
DB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTinwp-config.phpmatch your new server's database details—incorrect credentials are a common migration pitfall.
Once you can access the admin again, reconfigure AIOS carefully to match your new server's environment (for example, if you're on Nginx, you'll need to use Nginx-specific security rules instead of Apache's .htaccess).
内容的提问来源于stack exchange,提问作者Seba

