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