Remove www from your domain with .htaccess

This guide shows you how to remove www from your domain with .htaccess, so visitors always land on the non-www address.

Why show the domain without www?

When you remove www with .htaccess, your domain appears clean, without the www prefix, which is preferable in most cases. For example:
konet.gr
www.konet.gr

This offers:

  • Simplicity and clarity in the address bar.

  • SEO consistency, since duplicate content is avoided.

  • Better user experience, since the address is shorter and easier to remember.


The .htaccess file

The .htaccess file is a configuration file located in the public_html folder of your website (or in the root installation folder of a CMS such as WordPress/Joomla).

  • If it does not exist, you can create it manually.

  • It is a powerful tool because it lets you set up redirects, security improvements and caching settings.


Code for redirecting to non-www

To «force» your domain to load without www, use the following code:

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

Instructions:

  1. Replace yourdomain.com with your own domain.

  2. Make sure you keep https:// if you use SSL.

  3. Save the .htaccess file.


SEO Note: www or non-www?

Google has no preference between www and non-www. What matters is consistency:

  • Choose which version you want (with or without www).

  • Apply a permanent redirect (301 redirect).

  • Use the same version in Google Search Console.


Tips for CMS (WordPress, Joomla, Drupal)

  • WordPress: Also change the settings in Settings → General (WordPress Address and Site Address).

  • Joomla / Drupal: Check the base URL settings in the configuration.

  • If you do not align your CMS settings with .htaccess, redirect loops or conflicts may occur.


Frequently Asked Questions (FAQ)

1. What happens if I leave both www and non-www active?
There will be duplicate content, which has a negative effect on SEO.

2. Can I do the opposite (always show www)?
Yes, with a different rule in .htaccess. The logic is the same, but you redirect from non-www to www.

3. Will there be downtime?
No. The change takes effect immediately and users are redirected automatically.

4. What is R=301 in the code?
It is the HTTP code for a permanent redirect (301 Redirect). It tells search engines that the change is permanent.


At Konet, our servers (with LiteSpeed Enterprise & HTTP/3) fully support .htaccess rules. If you need help, you can always open a ticket with Support and we will apply the right setting for your domain.

 

Was this article helpful?

Related service Konet Web Hosting cPanel, LiteSpeed and automatic backups on every plan.

Related articles