How to force www with the url

Add the following in your .htaccess file

RewriteEngine off
RewriteCond %{HTTP_HOST} !^www\.creationInternetSite\.com$ [NC]
RewriteRule .?{REQUEST_URI} [R=301,L]
RewriteEngine on

Change creationInternetSite above by your own website name. Also be aware that since browser identifies webpages with www and webpages without www as two different webpage, if you are logged in with the website without www and then add this to your .htaccess, you will be logged out.

Also remember that for wordpress, you don’t need this method. If you want to force www to wordpress, follow this tutorial.