IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Force WWW to Your Domain URL

One important aspect of SEO basics is that we use “WWW Resolve” on our domain name. While we know that domain.com and www.domain.com may be pointing to the same website, search engines don’t know that and they will treat them as two duplicate websites and that’s going to hurt your page ranking. So it’s important to redirect all requests from a non-preferred domain into one URL.

The first step to do it is to setup our .htaccess file under our website directory. Open the file and put this on the very top. If you use WordPress, make sure you put these codes outside any WordPress custom codes.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^itnota.com$
RewriteRule ^/?$ "https://www.itnota.com/" [R=301,L]

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

Once the file is saved, you can test it by typing your domain.com (without the ‘www’) in your browser, the ‘www’ should be added automatically.

As the next step, you can also set how search engines would display your domain URL on their search result. For Google, you can use your Google account and sign up to Webmaster Tools and in Configuration – Settings you can set your Preferred domain.

Preferred Domain

With these two settings, you can be rest assured that Google will know how to display your URL correctly in its search result, and other http requests that don’t include ‘www’ in your domain will be corrected with the .htaccess settings.

Further Reading

Preferred domain (www or non-www)

November 9, 2012 Filed Under: How To Tagged With: Apache

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure