![How to Redirect WWW to non WWW WordPress [htaccess snippet]](https://i0.wp.com/bootstrapcreative.com/wp-bc/wp-content/uploads/2020/08/code-snippet.png?fit=1024%2C1024&ssl=1)
Below are two code recipes for your htaccess file to redirect different versions of your domain. Once you have things added you can use this redirect testing tool to verify all the versions of your domain are redirecting properly.
If you don’t want the WWW
Redirect everything to naked domain https://yourdomain.com
1 2 3 4 5 6 7 8 9 | # BEGIN Redirects RewriteEngine On # 301 redirect www to non-www RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https: |
If you want the WWW
Redirect everything to https://www.yourdomain.com
1 2 3 4 5 6 7 8 9 | # BEGIN Redirects RewriteEngine On # 301 redirect to www RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https: |