Force WWW in url


/ Published in: Apache
Save to your folder(s)

Using mod_rewrite in Apache to rewrite urls and force users to use www in urls. Good for letting search engine spiders in the right door...

Insert the code in your .htaccess-file in your website's root folder.


Copy this code and paste it in your HTML
  1. # force www in url
  2. RewriteEngine On
  3. RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
  4. RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  5. # END force www in url

URL: http://www.torkiljohnsen.com/2008/01/16/some-easy-use-of-mod_rewrite/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.