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.

simple 301 redirect - why it doesn't work?

Discussion in 'Apache' started by DomainMagnate, Sep 22, 2005.

  1. #1
    I wanted to redirect site.com to www.site.com so they get equal PR, backlinks etc.
    I've added this line to the end of my .htaccess file:
    redirect 301 / http://www.site.com/
    Code (markup):
    But when I tried to open the site, the page didn't load. The index page has no graphics and always loads very fast, so I waited only few seconds and tried this line:
    Redirect permanent / http://www.site.com
    Code (markup):
    With the same result - site isn't loading.

    So, do you have any ideas what's wrong? O May I should wait some time before the redirect starts working?

    if it helps, here is the tex which was in my .htaccess file before and stays now (i didn't change it). What does it mean exactly, is it good or not :rolleyes:

    <Files of>
    	ForceType application/x-httpd-php
    </Files>
    <Files aff>
    	ForceType application/x-httpd-php
    </Files>
    Code (markup):
    thanks, Mike
     
    DomainMagnate, Sep 22, 2005 IP
  2. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to get the syntax correct. These lines at the end of the file should do it.

    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)$ /http://www.site.com [R=301]
    Code (markup):
    Im not sure what the existing lines does, it doesnt look important to me. If you simply with to redirect the complete domain, you can safely remove those lines.
     
    Dejavu, Sep 22, 2005 IP
  3. DomainMagnate

    DomainMagnate Illustrious Member

    Messages:
    10,932
    Likes Received:
    1,022
    Best Answers:
    0
    Trophy Points:
    455
    #3
    I tried that now, but it doesn't work either. Anyway thanks for advice
     
    DomainMagnate, Sep 22, 2005 IP
  4. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry the first slash (/) should not have been there..
    this will definitely work. If it doesnt, your host probably dont support mod_rewrite

    [Edit]
    this will redirect whatever every page from site.com to the www.site.com homepage.. There is probably a better way redirect you to the same page within the site. From your example code I thought you wanted to forward a domain to another. (will teach me to read threads more carefully..)

    here is code for redirect from domain to www.domain
     
    Dejavu, Sep 22, 2005 IP
  5. DomainMagnate

    DomainMagnate Illustrious Member

    Messages:
    10,932
    Likes Received:
    1,022
    Best Answers:
    0
    Trophy Points:
    455
    #5
    Great, it works now!
    I hope it won't hurt any of my rankings ;) I'll let you know when it will be updated
     
    DomainMagnate, Sep 22, 2005 IP
  6. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #6
    To redirect to the same page that they tried to access, but on www.site.com instead of site.com use
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^site.com
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301]
    Code (markup):
     
    johnt, Sep 22, 2005 IP
  7. DomainMagnate

    DomainMagnate Illustrious Member

    Messages:
    10,932
    Likes Received:
    1,022
    Best Answers:
    0
    Trophy Points:
    455
    #7
    what is the difference exactly? I mean comparing to the post before with similar code
     
    DomainMagnate, Sep 22, 2005 IP
  8. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The $1 after www.site.com/ tells it use the page name that it found for the original request. So if they put in site.com/whatever.html, they will be redirected to www.site.com/whatever.html rather than just the home page
     
    johnt, Sep 22, 2005 IP
  9. DomainMagnate

    DomainMagnate Illustrious Member

    Messages:
    10,932
    Likes Received:
    1,022
    Best Answers:
    0
    Trophy Points:
    455
    #9
    Oh, great you've noticed!
    But something is wrong here, it doesn't work. May be you missed something?
     
    DomainMagnate, Sep 22, 2005 IP
  10. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Not that I can see. In what way doesn't it work ? Server 500 error ? It only redirects to the home page ?
     
    johnt, Sep 22, 2005 IP