Website URL Redirection Using wp-config.php
Log in to your Web hosting cPanel if you are using a custom domain. Alternatively, you can also FTP protocol to access the wp-config.php file of your website.
- In the cPanel, scroll down to the Files section.
- Double-click on File Manager option and click Submit to open the files. You will typically get the wp-config files under the public_html folder.
- Select the wp-config.php file and open it using Code editor to edit it as shown in the following figure.
- At the top of the wp-config.php file, just below the <?php option, add the following code replacing your full custom domain name.
Save the wp-config.php file and try to access your site without using www. The website should redirect to www.yourdomainname.com automatically.
WordPress Blog URL Redirection Using wp-admin
This method is more suitable and easy for WordPress Bloggers to force whether to use www for your website or not. Perform the following steps to complete the task.
- Log into your wp-admin dashboard of your website.
- Scroll down to the Settings section and select General to open the general settings.
- In the WordPress Address (URL) and Site Address (URL) sections, add www to the address for your full website domain name as shown in the following figure.
- Click Save Changes to save the changes. Access your website without using www, the website URL should automatically redirect to the www.yourdomainname.com address.
If you no longer want to access your website using www, just remove the www from the full domain name and save the changes.
That’s all you need to do to force your website/blog whether to use www or non-www URL address. If you have any further suggestion or method to achieve the same, please share with our readers.