I wanted to make sure not to serve duplicate urls on my site (with and without the www) and decided I would make sure my urls always have www.

In my .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

Note that because my entire site runs under https I just forward directly to that.


Like this post? Share it :)


Related Posts

Back