Troubleshooting Magento 404 Errors After Migration
You’ve successfully migrated your Magento site to a new server, but now you’re facing frustrating 404 errors on every page except the home page. The admin panel is also inaccessible. Let’s dive into this issue step-by-step.
1. Verify Your Base URL and Database Connection
First, ensure that the base URL in your core_config_data table matches the new domain name. Similarly, check if the database connection details in your local.xml file are accurate and the database is accessible.
<config>
<!-- ... other config data... -->
<global>
<install>
<date><![CDATA[Fri, 02 Jan 2015]]></date>
</install>
<session_save><![CDATA[db]]></session_save>
<resources>
<default_setup>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[]]></password>
<dbname><![CDATA[magentodb]]></dbname>
<active>1</active>
</connection>
</default_setup>
</resources>
</global>
</config>
2. Check Your .htaccess File
Your .htaccess file appears to be correctly configured for Magento’s usual setup. However, we need to ensure that the RewriteBase line is set appropriately based on where your Magento installation resides relative to the web root.
For example, if your Magento files are in a subdirectory called “magento,” you would update the RewriteBase line like this:
# RewriteBase /magento/
3. Disable Compilation and Flush Cache
Disable any compiler if it’s enabled on your system by running this command via SSH or terminal:
php -f compile.php disable
Then, flush all Magento cache using the following commands:
php -f shell/indexer.php --reindexall
rm -rf var/cache/*
rm -rf var/session/*
chmod 777 var/ -R
4. Rebuild Indexes and Flush Cache Again
Rebuild your indexes to ensure Magento has all the necessary data:
php -f shell/indexer.php --reindexall
Then, flush the cache again:
rm -rf var/cache/*
rm -rf var/session/*
chmod 777 var/ -R
5. Check Permissions and Ownership
Ensure that your Magento files have the correct permissions and ownership. All directories should be set to 777 (read, write, execute for everyone) or at least 755, and all files should be 644.
Conclusion: Debugging Further
If you’ve followed these steps and are still experiencing 404 errors, it’s time to enable Magento’s debug mode. Add the following line to your index.php file just above the <?php tag:
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
This will display any PHP errors that might be causing the issue.
Remember, it’s crucial to keep your Magento version up-to-date for security and compatibility reasons. If you’re still facing difficulties, don’t hesitate to reach out to a professional Magento developer or consider our expert support services at Laravel Company.
With these steps, you should be well on your way to resolving the 404 errors and accessing your admin panel again.