Last updated on November 25, 2022
For SEO reasons, you might always remove (or use) the www prefix in your URLs. The following snippet will remove the www from your website URL and redirect any URL with the www to the non-www version.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]