Hello,
Thank you for getting in touch with us.
To redirect your website from non-www to www, add the following lines in your website’s .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
Replace yourdomain.com with your actual domain name.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Thank you.
I have inserted this code and it works.
The issue I have found is that every time there is a plugin update this reverts to its original code without the redirect code.
Any advice on how to stop this from happening?
Hi, I have the same problem, so no need to open a new ticket since this is still open for new replies.
My site has a WWW Canonicalization as it shows in my Rank Math Analysis, and I can’t add those code in my .htaccess file because I don’t have access to it as my host support told me, and they suggest to use a simple redirection plugin to do it.
My question is: since Rank Math has a feature to use redirection, how can I use it to redirect all WWW to non-www and all http to https??
hi,
thanks for that advise. I have used this is the past. the issue re-occurs. Basically, when there is an update the code disappears.
Is there another solution?
Hello,
Did you add the code via Rank math or FTP? You can use the FTP method and let us know if it is still removed after every update
@Mehdi I have replied to your ticket:https://support.rankmath.com/ticket/i-cant-edit-htaccess-to-redirect-www-to-non-www/?view=all, please check.
Looking forward to helping you. Thank you.
​​​​​​
Hi. I updated it through a plugin called WP file manager.
I will try the ftp method
Hello,
You can also edit your htacess in Rank math > General Settings > Htaccess, here is a screenshot for reference: https://i.rankmath.com/gxqhKb . Let us know if this works for you.
Hope this helps.
Hello,
Glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.