Choisissez un autre pays ou une autre région pour voir le contenu spécifique à votre emplacement et faire des achats en ligne.
France
FR

How to remove ‘www’ from your WordPress website

Kyle Tapping
Kyle Tapping

Publié : 19/10/2022

Dernière mise à jour : 08/12/2022

Table des matières

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.

Inscrivez-vous pour recevoir gratuitement des nouvelles, des conseils et des offres

Votre courriel est en sécurité avec nous, nous ne faisons pas de 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.

Laisser un commentaire

Table des matières

Produits mentionnés
Shared Web Hosting (cPanel)
Windows Plesk Hosting
Inscrivez-vous pour recevoir des offres et les dernières nouvelles

Connexion revendeur

Si vous êtes un revendeur, utilisez le bouton ci-dessous pour vous connecter. (votre compte revendeur est distinct de votre compte habituel)

Nouveau client

Nouveau sur ELITEWEB.Co ? Créez un compte pour commencer dès aujourd’hui.

Utilisateurs enregistrés

Vous avez un compte ? Connectez-vous maintenant.

Sign up for offers and the latest news