Category Archives: Apache

Leave a comment

by | May 23, 2012 · 1:21 pm

How to force WWW in a URL

I’ve come across this problem today so I’ll leave here the solution if you are using a Apache server.

So Editing (or adding ) the .htaccess you need to have this code included there:

RewriteEngine on

For FORCING www.
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^(YOUR_DOMAIN_NAME\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$$1 [R=301]

This should solve it.

Leave a comment

Filed under Apache