Magento non www to www

Magento non www to www

August 26, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento non www to www

How to Fix Non-www to www RedirectIssues in Magento: A Comprehensive Guide

Are you facing a frustrating issue where non-www URLs redirect to your homepage instead of the intended CMS page in your Magento store? You’re not alone, and I’m here to help you resolve this headache-inducing problem once and for all.

The Root Cause

The issue typically arises due to incorrect configuration or misplaced redirects in your .htaccess file. Magento’s core configuration is set up to redirect non-www URLs to the homepage for security and SEO purposes. However, sometimes this redirection doesn’t apply correctly to specific CMS pages, causing the URL to break.

The Simplest Solution: Edit Your .htaccess File

The quickest fix involves editing your .htaccess file directly. Here’s how:

  1. Access your server using an FTP client or SFTP.
  2. Locate and open the .htaccess file in your Magento root directory for editing.
  3. Add the following lines at the end of the file, just before the closing </IfModule> tag:
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]

Replace ‘yourdomain.com’ with your actual domain name.

  1. Save the changes and upload the modified file back to your server, overwriting the existing one.

This code snippet tells Apache to redirect any request for the non-www version of your domain to the www version using a 301 permanent redirect. The [L,R=301] flag ensures that the redirection is permanent in the eyes of search engines and browsers.

When Direct Editing Fails

If you’ve tried this method and are still experiencing issues with specific CMS pages, it might be due to custom rewrites or overrides applied only to those pages. In this case, you’ll need to dig a bit deeper:

  1. Check your Magento admin panel for any URL rewrite rules specifically targeting the problematic page(s). Navigate to Stores > Configuration > SEO & Search > Search Engine Optimization -> URL options.

  2. Ensure that the Base URLs are correctly configured as http://www.yourdomain.com under both “Unsecure” and “Secure” settings in the same configuration section.

  3. If you’ve enabled URL rewrites for your CMS pages, verify that they are pointing to the correct www version of the URL.

A Word on SEO Implications

Using 301 redirects is crucial because it signals search engines that the change is permanent, ensuring they update their index accordingly. This helps preserve your site’s ranking and prevents duplicate content penalties.

However, be cautious when applying redirects, as excessive or incorrect redirects can negatively impact your site’s performance and user experience. Always double-check your configurations to prevent unnecessary redirection loops or broken URLs.

Conclusion

Fixing non-www to www redirect issues in Magento requires a combination of understanding your store’s configuration and making targeted adjustments to the .htaccess file or URL rewrite rules. By following this comprehensive guide, you should now be equipped to resolve this common problem efficiently.

Remember that keeping your site’s configuration consistent and well-optimized is key to maintaining a healthy online presence. If you find yourself struggling with more complex SEO or performance issues, don’t hesitate to reach out to the experts at LaravelCompany, where we specialize in helping businesses like yours thrive through expert Magento development services.

Happy coding!

Security Extensions Configuration SEO

Our network