How to Redirect WWW Version to Non-WWW Version of Your Website


If you’re trying to deal with URLs on your website redirecting to the incorrect variations, you may have to redirect the WWW version of your website to the non-WWW version of your site (if that’s the primary URL of your site) or vice versa. Luckily, besides all the cool behind-the-scenes improvements in Rank Math, it also makes it extremely easy to fix the dreaded “redirection of non-www to www version” in no more than a few minutes…

In this knowledgebase article, we’re going to walk you through how to redirect the www version to the non-www version of your website.

How to Redirect www Version to Non-www Verison in Rank Math

To redirect your pages to non-www URLs, you’ll need to apply the change at the full-site level. The redirect helps you avoid page duplication and poor user experience. To redirect www to the non-www version, you’ll need to enter a piece of code in the .htaccess file.

1 Edit .htaccess File

Rank Math lets you edit your website’s .htaccess file right inside the WordPress dashboard. To edit the file, navigate to the WordPress Dashboard > Rank Math > General Settings > Edit .htacess as shown below:

Rank Math edit .htaccess settings

2 Add the Redirection Rule

 To add a redirection rule to your .htaccess file, click the check box below the warning and add the code snippet after #END WordPress.

Add the redirection rule

Add the following code snippet and click on Save Changes.

RewriteEngine On
RewriteCond %{HTTP_HOST}
RewriteRule (.*)$1 [R=301,L]

If the issue still persists then try the following code snippet instead:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

And that’s it! You have successfully enabled a .htaccess rule that will redirect all visitors from a www version to the non-www version of your website! If you still have any questions about how to redirect the www version to the non-www version of your website – you’re always more than welcome to contact our dedicated support team. They are available 24/7, 365 days a year…

This post was originally posted here

Check out our Starter Sites built with #ToolWeLove including Toolset, Elementor Pro, and Astra Pro.


Share this page
Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on email
How to Choose WordPress Hosting

Pixallus WordPress Hosting. Simplified. Enjoy blazing fast WordPress website loading speeds and 99.9% uptime. Whether you’re a freelancer, small business, or a large organization, we

Read More »