1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

htaccess redirecting

Discussion in 'Apache' started by 993ti, Nov 4, 2005.

  1. #1
    Well, i found out that msn is indexing the wrong url to my site so i'm using htaccess to send it to the correct url.
    I can redirect the url without www but how do i redirect the www?
    I tried it but it didn't work :S
    What am i doing wrong here:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^wrong_domain.nl$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.wrong_domain.nl$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^domain.com$ [NC] 
    RewriteRule /(.*) http://www.correct_domain.com/$1 [R=301,L]
    Code (markup):

     
    993ti, Nov 4, 2005 IP
  2. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just check if you're *not* at the right domain and then redirect it :)
    <IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase / 
    RewriteCond %{HTTP_HOST} !^www\.your_correct_domain\.com [NC] 
    RewriteRule ^(.*) http://www.your_correct_domain.com/$1 [L,R=301] 
    </IfModule> 
    
    Code (markup):
     
    exam, Nov 4, 2005 IP
    993ti likes this.
  3. 993ti

    993ti Well-Known Member

    Messages:
    314
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thx!
    That worked :)
    I've got 2 htaccess files, one in the root folder and one in the www folder.
    The one in the www folder didn't work.
     
    993ti, Nov 5, 2005 IP
  4. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Create your www subdomain and just point it to the same folder (root folder) that the non-www version of your domain goes to, and the .htaccess file will do the rest.
     
    exam, Nov 5, 2005 IP