“Unleash the Secret Trick to Easily Redirect Your WordPress Site from Non-www to Www – Boost Your SEO and Bring in More Traffic Now!”
Redirecting Non-WWW URLs to their WWW Counterparts in WordPress
For website owners, directing non-www URLs to their www counterpart has become a crucial SEO factor since search engines consider both URLs as different entities. If you’re using WordPress and would like to direct your non-www URLs to their www counterpart, this article will show you how to do it.
Understanding Non-WWW and WWW URLs
Essentially, a non-www URL is a domain name without the prefix “www” such as example.com. In contrast, www URLs include “www” before the domain name, such as www.example.com. While both URLs are technically the same, search engines treat them as separate entities. To avoid confusion, it’s better to direct your non-www URLs to their www counterparts.
Steps to Redirect Non-WWW to WWW in WordPress
1. Access your website database through phpMyAdmin
To begin, access phpMyAdmin by going to your website’s cPanel dashboard. Click on the phpMyAdmin icon, which should take you straight to your database’s login screen. From there, input your login details and navigate to your WordPress database by selecting it from the left sidebar.
2. Locate the .htaccess file
The .htaccess file typically contains some rules that govern how your website handles web traffic. To find this file, click on the file explorer icon, then select your website directory. Locate the .htaccess file, right-click on it, and select “Download” to save it to your local machine. Once you’ve accessed your .htaccess file, you can now proceed to the next step.
3. Open the .htaccess file and redirect non-www URLs to www
Once you’ve located the .htaccess file, open it in a text editor like Notepad on a Windows computer or TextEdit for Mac users. Next, enter the following code (without the quotations) just below the “# END WordPress” line.
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The following breakdown explains the code above:
- The first line, RewriteEngine On, activates the URL rewriting engine, which is a powerful feature that enables users to rewrite website URLs.
- The second line, RewriteCond %{HTTP_HOST} !^www\. [NC], instructs the server to check whether the requested domain does not include “www”. If the condition is true, the redirect will occur.
- Finally, the third line, RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L], redirects all non-www URLs to www URLs.
After adding the code above, save the .htaccess file and re-upload it to your website.
4. Test your redirect
To ensure that your redirect is working correctly, visit your website by entering your previous non-www URL (e.g., example.com) into your browser’s address bar. If your website now loads with the www prefix, then your redirect has been successful.
Conclusion
Redirecting non-www URLs to their www counterparts on a WP website is straightforward, and it’s crucial for SEO purposes. Using the steps outlined above, you can easily redirect your traffic using the .htaccess file within your hosting server. Once you’ve set up the 301 redirect successfully, it’s essential to verify that the redirect is working on all pages so that search engines can crawl them effectively.