SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Nov 2002
    Location
    Vancouver, BC
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect to www. using mod_rewrite

    I tried searching for this but everybody seems to want to go from www. to a non www. url. I on the other hand want the www.

    I found htis code on a lot of sites and examples but i don't know how to modify it so that if someone visits http://site.com they go to http://www.site.com

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.domain\.com
    rewriterule (.*) http://www.domain.com/$1 [R=permanent,L]



    Thanks

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this then:

    Code:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [R=permanent,L]

    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •