Frequently Asked Questions
How do I redirect users from non www to www (or visa versa)
Last Updated 6 years ago
If you want to ensure users are redirected to the correct URL on your website you can add the following snippet of code to your .htaccess file:
Let's say I have a website called www.mydomain.com and I want to ensure mydomain.com redirects to www.mydomain.com, we can add the following:
If you want to do it in reverse, www.mydomain.com to mydomain.com then we add this:
Note: If you don't have a SSL/TLS certificate installed then remove the 's' from the above URLs.
Let's say I have a website called www.mydomain.com and I want to ensure mydomain.com redirects to www.mydomain.com, we can add the following:
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [L,R=301]
If you want to do it in reverse, www.mydomain.com to mydomain.com then we add this:
RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC]
RewriteRule ^(.*)$ https://mydomain.com/$1 [L,R=301]
Note: If you don't have a SSL/TLS certificate installed then remove the 's' from the above URLs.
Please Wait!
Please wait... it will take a second!