Posted By

torkil on 01/16/08


Tagged

url modrewrite htaccess apache www seo domains


Versions (?)

Who likes this?

8 people have marked this snippet as a favorite

basicmagic
adix
cbrant
vertoo
torkil
not_skeletor
bpa
vali29


Force WWW in url


 / Published in: Apache
 

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

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.

  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

Report this snippet  

You need to login to post a comment.