Skip to content

How to force no-www URLs to www version URLs with htaccess?

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]
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments