Submit Your Article Forum Rules

Results 1 to 3 of 3

Thread: ModRewrite: How to redirect [domain].com to www.[domain].com

  1. #1
    Junior Member
    Join Date
    Oct 2004
    Posts
    10

    ModRewrite: How to redirect [domain].com to www.[domain].com

    I need to redirect as suggested in the subject. I actually found some code but it seems to be doing 302s. Can someone help me out and post the code for mod rewrite that does this? The current code I have is the following:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !www.domain.com
    RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [R]

    Thanks.

  2. #2
    Senior Member Deep13's Avatar
    Join Date
    Dec 2003
    Posts
    302
    try this and see

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !www.domain.com
    RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

    you can also check your headers here

    Regards
    Deep

  3. #3
    Code:
    <HEAD><meta http-equiv="refresh" content="0; URL=http://www.yoursite.com"></HEAD>
    This will work if you name index.html

Similar Threads

  1. Redirect domain to SUB domain ??
    By DVDStar in forum Search Engine Optimization Forum
    Replies: 0
    Last Post: 06-27-2008, 01:01 PM
  2. sub-domain to domain redirect
    By Topglue in forum Search Engine Optimization Forum
    Replies: 1
    Last Post: 01-30-2008, 05:39 PM
  3. Redirect vs domain name
    By urcleanandlean in forum Search Engine Optimization Forum
    Replies: 3
    Last Post: 05-16-2006, 03:18 PM
  4. 301 redirect from domain.com to www.domain.com
    By braknews in forum Search Engine Optimization Forum
    Replies: 3
    Last Post: 12-14-2005, 04:56 PM

Posting Permissions

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