Magento: Resolving 404 Errors on Product Pages for Multiple Stores
You’re experiencing a common issue when managing multiple Magento stores with different domainsâ404 errors appearing on product pages after enabling them in the second store. This usually happens due to misconfigured base URLs or incorrect URL rewrites.
Understanding the Issue
In your case, you have two storesâone at http://www.bioaigua.es and another at http://www.bionaigua.net. When products are enabled for both stores, Magento should create separate URLs for each product in each store. However, the 404 errors indicate that the URLs aren’t being generated correctly or the URL rewrites aren’t working as expected.
Step-by-Step Solution
Let’s resolve this issue by following these steps:
-
Check Base URLs First, ensure your base URLs are configured correctly in the Magento admin panel.
- Go to System > Configuration > General > Web.
- In the Unsecure and Secure sections, check if the Base URL fields contain the correct domain names for each store.
-
Verify URL Rewrite Generation Magento should automatically generate URL rewrites for each product when you enable them in a new store view. Let’s check if these are present.
- Log in to your MySQL database using a client like phpMyAdmin or Navicat.
- Look at the
core_url_rewritetable. - You should see entries for both domains.
-
Manually Generate URL Rewrites If the URL rewrites aren’t present, you can manually generate them:
- In your Magento admin panel, go to System > Tools > Configuration Reset.
- Select “Reset all URLs” and click ‘Submit’.
- This will clear the existing URL rewrites and allow you to regenerate them.
-
Update the .htaccess File Sometimes, the
.htaccessfile can prevent Magento from generating proper URLs. Check if your.htaccessfile is correctly configured.- Look for a line that starts with
RewriteBase. It should match the base URL of your Magento installation (e.g.,/magento/). - Ensure there are no extra lines or unnecessary redirects.
- Look for a line that starts with
Best Practices
To avoid this issue in future:
- Always use absolute paths when linking between stores.
- Regularly update your URLs during development to prevent any discrepancies.
- Keep your Magento version and extensions up-to-date for better URL handling.
Conclusion
Resolving 404 errors on product pages requires careful configuration of base URLs, manual URL rewrite generation if necessary, and regular maintenance of your .htaccess file. By following the steps outlined above, you should be able to successfully resolve this issue and ensure that your products appear correctly across all stores.
Remember, proper URL management is crucial for a smooth user experience and effective SEO in Magento multi-store setups.
Further Reading
For more detailed information on Magento URL management and best practices, I recommend checking out our comprehensive guide: Laravel Company’s Guide to Magento Multi-Store Configuration.