How to Redirect non-WWW Version to 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 non-WWW version of your website to the 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 less than a few minutes…

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

How to Redirect Non-WWW Version to WWW Version

To redirect non-www to 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 inside the WordPress dashboard. To edit the file, navigate to the WordPress Dashboard > Rank Math > General Settings > Edit .htacess as shown below:

Edit .htaccess file in Rank Math

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 code to .htaccess file

Add the following code snippet and click on Save Changes.

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

You can use the htaccess tester tool to debug and ensure that the rewrites are correct before adding them to the .htaccess file.

And that’s it! You have successfully enabled a .htaccess rule that will redirect all visitors from a non-www version to the www version of your website! If you still have any questions about how to redirect the non-www version to the 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…

Was this article helpful?

Still not using Rank Math?

Setup takes less than 5 minutes including the import from your old SEO Plugin!

Learn more about the PRO Version

Still need help?


Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles