Redirected to the Homepage when removed www. from URL

Redirected to the Homepage when removed www. from URL

October 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Redirected to the Homepage when removed www. from URL

Why Removing “www.” Redirected You to Your Homepage

If you’re finding that when you remove “www.” from your URL (e.g., switching from www.example.com/contactus to example.com/contactus), it redirects you to the homepage, you’ve likely encountered a common issue with domain canonicalization. Let me explain what’s happening and how you can resolve this.

Understanding Domain Canonicalization

Domain canonicalization is the process of ensuring that your website appears under one specific domain name. This prevents issues like duplicate content, split SEO authority, and user confusion caused by multiple domain versions (e.g., both www and non-www).

The way you handle this depends on whether you want to force all traffic to use either “www” or the root domain.

Why Your Current .htaccess Redirects to Homepage

Given your provided .htaccess file, it appears that you’ve configured a rewrite rule using the R=301 flag. This tells Apache to issue a 301 redirect (permanent redirection) whenever a non-www URL is accessed.

The line you shared:

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Translates to: If the requested host is example.com, redirect it to http://www.example.com with a permanent 301 status.

How to Fix This Redirect Issue

To resolve this, you have two main options:

  1. Force all traffic to use “www” using your current approach.
  2. Choose one version and canonicalize it properly.

If you want to stick with the www version (which is usually recommended for SEO purposes), ensure that your A record in DNS points to your server’s IP address. This should resolve the redirection issue while keeping all traffic under the “www” domain.

However, if you prefer using the root domain (example.com) without “www”, I recommend following these steps:

Canonicalizing the Root Domain

  1. Remove or comment out your current rewrite rule in .htaccess.

  2. Update your DNS settings:

    • Remove any A records for www and redirect them to the IP address of your domain (if applicable).
    • Ensure the A record for your root domain points to your server’s IP address.
  3. Set up canonicalization in your website platform:

    • If you’re using Laravel, add this line to your config/app.php file:
      'url' => 'https://example.com',
      
    • Ensure that any absolute URLs generated by the framework use this base URL.
  4. Update SEO settings:

    • Tell search engines which version is the preferred one. If you choose www, add a rel=“canonical” meta tag to your pages pointing to the “www” version.
    • Configure Google Search Console and Bing Webmaster Tools with the chosen domain version.

Conclusion: Choosing Your Preferred Domain

The key takeaway is that you need to select either the root domain or the www subdomain as your primary address. Consistency is crucial for SEO, user experience, and domain authority.

  • If you opt for www, ensure it’s properly configured in DNS and .htaccess.
  • If you prefer the root domain, update DNS settings, canonicalize URLs, and configure SEO accordingly.

Stick to one version consistently across your website, and ensure all redirects are clean and well-managed. This will help avoid issues like the redirection you’ve been experiencing.

For more comprehensive guides on URL handling in Laravel, I recommend checking out our detailed tutorials on Laravel Company.

Deployment SEO Errors

Our network