United States
USA

How to remove ‘www’ from your WordPress website

Kyle Tapping
Kyle Tapping

Published: October 19, 2022

Last updated: October 19, 2022

Table of Contents

remove www from wordpress url and redirect

Have you ever wanted to remove www from your web address? If you have, this is the post for you.

How to remove ‘www’ from your WordPress URL

Removing the www. prefix from your WordPress website is very easy to do. Simply follow the below steps:

  • Login to your WordPress dashboard
  • Go to Settings -> General
  • Scroll down to WordPress Address (URL) and Site Address (URL)
  • Remove the www. prefix from both fields
  • Scroll down and press ’Save Changes
WordPress general settings - update site URLs
Above: WordPress General Settings

Once you have done this you will want to ensure that you’re redirecting your visitors to the correct non-www website. The reason why is that if you’re using a caching service, your visitors will likely still be able to load your website using ‘www.’, this can potentially result in them being served outdated files and they may see an older/broken version of your website. You will be glad to know that fixing and preventing this issue is very simple to do, and I am going to walk you through every step of the way.

How to redirect to non-www on Apache

  1. Open your file manager, this is found in your cPanel or your Managed hosting platform. If you’re unsure where to find it you can contact your hosting provider and they will help you. If you’re an Elite customer contact us here.
  2. Then you need to find your .htaccess file, which is found in your file manager in your public_html folder. If you cannot see your .htaccess file click on settings in the top right of your file manager and check ’show hidden files (dotfiles)
find htaccess in file manager
Above: Showing hidden files in the file manager
  1. Now you’ve found your .htaccess file, commonly found just under wp-includes in the public_html folder, download it so you have a copy, then right-click and press edit, or click it once and press edit at the top of your screen.
  2. Lastly, you need to add the below code at the top of your .htaccess file.

Below is the code for non-www redirect and use of SSL (HTTPS – recommended)

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://examplewebsite.com/$1 [R=301,L]

Below is the code for non-www redirect and no SSL (HTTP)

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

NOTE: replace ‘examplewebsite.com’ with your own domain name.

  1. Press ’Save Changes’

How to redirect to non-www on Windows

Windows servers work differently than Apache servers, they use a web.config file to hold configuration settings.

This XML file is easily editable. However, you still need to make a backup of the file before making any changes. This way you can revert any changes, should anything break.

  1. Navigate to the web.config file (contact your host to find it, if you’re struggling)
  2. Make a backup of the file
  3. Open the file
  4. Scroll down to the <system.webServer> section
  5. Add the below code in replacement in between the <rules> </rules> tags
<system.webServer>
  <rewrite>
    <rules>
      <rule name="non-www redirect" enabled="true" stopProcessing="true">
        <match url=".*" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^www.(.*)" />
        </conditions>
        <action type="Redirect" redirectType="Permanent" url="https://{C:1}{REQUEST_URI}" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

NOTE: replace ‘url=“https://…’ with ‘url=“http://…’ for non SSL traffic

Conclusion

And just like that, in a few simple steps, you can streamline your URL even more and remove the unnecessary www from your web address.

Sign up for free news, tips & offers

Your email is safe with us, we don't spam.

Kyle Tapping
Kyle Tapping
Kyle joined the Elite team in 2018. With a background in website development and search engine optimization, Kyle takes great satisfaction from spreading his knowledge to help others succeed in the world of the web. His interests include website development, Brazilian Jiu-Jitsu, coding, and graphic design.

Leave a Reply

New customer

New to ELITEWEB.Co? Create an account to get started today.

Registered users

Have an account? Sign in now.

Reseller login

If you’re a reseller, use the button below to sign in. (your reseller account is separate to your regular account)

New customer

New to ELITEWEB.Co? Create an account to get started today.

Registered users

Have an account? Sign in now.

Sign up for offers and the latest news