Magento 1.9.X服务器迁移后无法登录及后台404错误求助
Hey there, let's work through this Magento admin 404 issue you're facing after migration. Based on the steps you outlined, here are targeted troubleshooting fixes to get things back on track:
First, let's recap your workflow to align on context:
- Packaged the Magento instance on the old server (excluding the
downloadfolder) - Exported and compressed the MySQL database
- Unpacked the instance on the new server, imported the old database
- Updated
web_secureandweb_unsecurevalues incore_config_data
Now let's dive into fixing that admin 404 error:
1. Double-Check Admin URL Settings in core_config_data
You updated the frontend URLs, but it's easy to overlook the admin path configuration. Run this SQL query in your new database to verify:
SELECT * FROM core_config_data WHERE path LIKE 'admin/url/%';
- If you use a custom admin path: Ensure
admin/url/custommatches your new server's admin URL, andadmin/url/use_customis set to1. - If you use the default admin path: Make sure
admin/url/use_customis0andadmin/url/customis empty.
2. Flush All Magento Cache (Don't Skip This!)
Migration almost always leaves stale cache files hanging around, which can break URL routing. You can flush cache two ways:
- Command Line (recommended): SSH into your new server and run:
# For Magento 2 php bin/magento cache:flush php bin/magento cache:clean # For Magento 1 php shell/cache.php --flush - Manual Flush: Delete all folders inside
var/cache/,var/page_cache/(Magento 2 only), andvar/generation/(Magento 2 only).
3. Fix File Permissions
Incorrect permissions are one of the most common causes of 404s post-migration. Set the correct permissions based on your Magento version:
# Magento 2 Permissions find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; chmod u+x bin/magento chown -R www-data:www-data /path/to/your/magento/instance # Adjust user/group to match your server # Magento 1 Permissions find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; chmod 777 var/ var/media/ var/session/ var/tmp/ chown -R www-data:www-data /path/to/your/magento/instance
4. Verify Rewrite Rules and .htaccess
- Ensure the hidden
.htaccessfile was copied over from the old server—hidden files are easy to miss during packaging. If it's missing, grab a fresh copy matching your Magento version. - For Apache users: Confirm
mod_rewriteis enabled with these commands:a2enmod rewrite systemctl restart apache2 - For Nginx users: Double-check that your server block includes the official Magento rewrite rules to handle URL routing correctly.
5. Rule Out the download Folder Exclusion
While excluding the download folder shouldn't impact the admin directly, it's worth copying it over from the old server just to eliminate any edge cases. Some older Magento versions use this folder for specific asset storage, and missing files here could cause unexpected 404s for admin resources.
6. Confirm Server Document Root
- For Magento 2: Your server's document root must point to the
pubfolder—not the main Magento root. If it's set incorrectly, this will break both frontend and admin URLs. - For Magento 1: The document root should point directly to the main Magento folder.
If you can share more details about what happens when you enter the other URL (e.g., frontend loading issues, different error messages), we can narrow this down even further!
内容的提问来源于stack exchange,提问作者Device Developer

