PrestaShop

PrestaShop Migration 404 Error? The .htaccess Fix You Need

Migrating a PrestaShop store, whether to a new domain, a different server, or even just a subdirectory, is a common yet often intricate process. While the promise of a fresh start or improved performance is exciting, the journey can sometimes lead to unexpected roadblocks. One of the most frustrating and frequently encountered issues is the dreaded '404 Page Not Found' error, which can bring your entire e-commerce operation to a halt.

At Migrate My Shop, we've seen countless scenarios, and this particular challenge, highlighted in a recent PrestaShop forum thread, offers a perfect illustration of a common pitfall and its surprisingly straightforward solution. Let's dive into why this happens and how to fix it, ensuring your migrated PrestaShop store goes live without a hitch.

PrestaShop admin panel URL confirmation notification
PrestaShop admin panel URL confirmation notification

The Migration Blueprint: Essential First Steps (and Where They Can Fall Short)

Our forum user, raunharman, diligently followed several critical steps when migrating their PrestaShop store from one domain to another on the same server. These are foundational for any successful PrestaShop migration:

  • Database URL Updates: The URLs were correctly updated in the ps_shop_url table (specifically domain and domain_ssl) and other relevant configuration tables, such as ps_configuration for PS_SHOP_DOMAIN and PS_SHOP_DOMAIN_SSL. These entries are paramount as they tell PrestaShop its new home address.
  • Database Credentials: The app/config/parameters.php file (or config/settings.inc.php for older versions) was updated with the correct database name, username, and password. This ensures your PrestaShop installation can connect to its data.
  • Cache Clearing: The var/cache directory was cleared. This is a crucial step to remove any old cached data, Smarty templates, or configuration files that might still reference the previous domain or settings.
  • File Placement Verification: As rightly pointed out by ComGrafPL in the forum thread, ensuring all PrestaShop files are placed in the correct directory below public_html (or your web root) is fundamental. Incorrect file paths can lead to immediate 404s or server errors.

Despite these seemingly comprehensive steps, the store continued to display a 'Page Not Found' error. This is a classic scenario where all the obvious bases are covered, yet a critical, often overlooked, piece of the puzzle remains missing.

A digital illustration of a broken link icon with a PrestaShop logo in the background, symbolizing a 404 error after migration.
Don't let a 404 error halt your PrestaShop migration. Understanding the root causes is key.

The Breakthrough: Unlocking the Admin Panel and the Critical Notification

Fortunately, raunharman managed to access the PrestaShop admin panel. This proved to be the pivotal moment, as the back office displayed a critical notification:

Action required: confirm your store URL
We've noticed that your store's URL no longer matches the one registered in your PrestaShop Account. For your services to function properly, you must either confirm this change or create a new identity for your store.
- Current store URL: https://gniautoparts.co.in/presta
- URL registered in PrestaShop Account: https://raunharman.co.in/presta2

This notification is PrestaShop's way of telling you that while you've updated some database entries, its internal routing system, particularly how it handles friendly URLs, is still configured for the old domain. It's a clear signal that the system needs to re-evaluate its URL structure.

The .htaccess Revelation: PrestaShop's URL Rewriting Engine

The solution, as discovered by raunharman, lay in regenerating the .htaccess file. But why is this file so crucial, and why does it often cause 404s after a migration?

The .htaccess file is a powerful configuration file used by Apache web servers. In PrestaShop, it plays a vital role in:

  • Friendly URLs: It enables PrestaShop to transform complex URLs (e.g., index.php?id_product=1&c>) into clean, SEO-friendly ones (e.g., /my-product-name.html).
  • Redirections: It handles various redirects, ensuring visitors and search engines are directed to the correct pages.
  • Security & Performance: It can also manage security rules, caching, and other server-level configurations.

When you migrate your store to a new domain or subdirectory, the rewrite rules within the existing .htaccess file often still point to the old location. This mismatch causes the server to fail in finding the requested resources, resulting in a 404 error for both the front and back office.

How to Regenerate Your .htaccess File in PrestaShop:

  1. Access Your Admin Panel: Even if your front office is down, try to access your back office. Often, the admin URL might still work, or you might need to temporarily disable friendly URLs via the database (set PS_REWRITING_SETTINGS to 0 in ps_configuration table) to gain access.
  2. Navigate to SEO & URLs: Go to Shop Parameters > SEO & URLs.
  3. Save Settings: Without making any changes, simply scroll to the bottom and click the "Save" button. This action forces PrestaShop to regenerate the .htaccess file with the current, correct store URLs and paths.
  4. Verify: After saving, clear your browser cache and try accessing your front office. Both front and back ends should now be working correctly.

In some rare cases, if regenerating doesn't work, you might need to manually delete the existing .htaccess file from your PrestaShop root directory via FTP/SFTP and then perform the regeneration step. Also, ensure your server has the Apache mod_rewrite module enabled, as it's essential for friendly URLs to function.

A screenshot mock-up of the PrestaShop admin panel showing the 'Action required: confirm your store URL' notification.
The crucial "Action required: confirm your store URL" notification in the PrestaShop admin panel.

Beyond the Fix: Proactive PrestaShop Migration Best Practices

While the .htaccess regeneration is a common fix, a successful PrestaShop migration involves more than just addressing 404s. Here are some best practices from Migrate My Shop:

  • Comprehensive Backup: Always, always, always create a full backup of your database and files before starting any migration.
  • Staging Environment: Perform the migration on a staging or development environment first. This allows you to test everything thoroughly without affecting your live store.
  • Verify Server Requirements: Ensure your new hosting environment meets PrestaShop's specific PHP version and extension requirements.
  • Check File Permissions: Incorrect file permissions can cause various issues, including inability to write cache files or upload images.
  • Disable Cache/CDN: Temporarily disable PrestaShop's cache, any third-party caching modules, and CDN services during the migration process. Re-enable them once everything is confirmed working.
  • Review Modules and Themes: Some modules or themes might have hardcoded URLs or specific configurations that need updating after a domain change.
  • Test All Functionality: After migration, rigorously test every aspect of your store: product pages, categories, search, checkout process, customer accounts, contact forms, and payment gateways.

Conclusion

The '404 Page Not Found' error after a PrestaShop migration can be daunting, but as this forum thread illustrates, the solution is often found within the PrestaShop admin panel itself. By understanding the role of the .htaccess file and the importance of confirming your store's URL, you can quickly resolve this common issue.

At Migrate My Shop, we specialize in seamless PrestaShop migrations, ensuring your store transitions smoothly without downtime or data loss. If you're planning a migration or facing persistent issues, don't hesitate to contact our experts. We're here to help you navigate the complexities and get your e-commerce business thriving on its new home.

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools