How to remove ‘www’ from your WordPress website
Kyle Tapping
Published: 19/10/2022
Last updated: 08/12/2022
Table of Contents
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’
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
- 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.
- 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)’
- 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.
- 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.
- 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.
- Navigate to the web.config file (contact your host to find it, if you’re struggling)
- Make a backup of the file
- Open the file
- Scroll down to the <system.webServer> section
- 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.
Related
Sign up for free news, tips & offers
Your email is safe with us, we don't spam.