Why won't my 301 redirect work?

Discussion in 'Apache' started by AdsenseOptimized, Jan 2, 2006.

  1. #1
    Under the main public_html folder lies all the files for my site, including .htaccess. I added

    redirect 301 / http://www.domain.com/

    under neath the code and it won't work, why not?

    Derek
     
    AdsenseOptimized, Jan 2, 2006 IP
  2. wrmineo

    wrmineo Peon

    Messages:
    3,087
    Likes Received:
    379
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try to htaccess under your www folder?
     
    wrmineo, Jan 2, 2006 IP
    AdsenseOptimized likes this.
  3. AdsenseOptimized

    AdsenseOptimized Peon

    Messages:
    187
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thats the one I'm using...I think it's the same as the public_html but I'm using the www folder one.

    Derek
     
    AdsenseOptimized, Jan 2, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Try

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^$ http://www.domain.com/ [R=301,L]

    domain.com/.htaccess
     
    Nintendo, Jan 2, 2006 IP
    AdsenseOptimized likes this.
  5. AdsenseOptimized

    AdsenseOptimized Peon

    Messages:
    187
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you mean just that, delete all other code in the file?

    Derek
     
    AdsenseOptimized, Jan 2, 2006 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    Just that, unless you got code for other stuff.
     
    Nintendo, Jan 2, 2006 IP
  7. AdsenseOptimized

    AdsenseOptimized Peon

    Messages:
    187
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    still not working...it fives me a 500 internal error
     
    AdsenseOptimized, Jan 2, 2006 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    I don't know if it'll fix it, change

    RewriteRule ^$
    to
    RewriteRule ^index.XXXX$

    XXXX being what ever the extension is.
     
    Nintendo, Jan 2, 2006 IP
  9. AdsenseOptimized

    AdsenseOptimized Peon

    Messages:
    187
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    no dice

    Derek
     
    AdsenseOptimized, Jan 2, 2006 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #10
    Have you done mod_rewrite before? Try this test...

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index\.wacko$ index.WHATEVER [L]

    Change WHATEVER to the current extension, upload it, then go to domain.com/index.wacko If that doesn't work then I don't think mod_rewrite will work. And mod_rewrite doesn't work on Windows servers.
     
    Nintendo, Jan 2, 2006 IP
  11. eKstreme

    eKstreme Guest

    Messages:
    131
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Another thing: Clear your cache before you try it. Sometimes that helps...
     
    eKstreme, Jan 3, 2006 IP
  12. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi,

    Make sure you upload the .htaccess file in ASCII mode. If you don't know, upload the file as htaccess.txt and rename it to .htaccess when it is on the server.

    Did you ask your hosting company whether they allow you to use .htaccess ?

    Jean-Luc
     
    Jean-Luc, Jan 3, 2006 IP
  13. AdsenseOptimized

    AdsenseOptimized Peon

    Messages:
    187
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #13
    no I haven't asked them that. But .htaccess was already a file in that folder...it was there automatically...

    also, with nintendo's last post, the .htaccess forlder then has no domains in it so how does it know where to go?
     
    AdsenseOptimized, Jan 3, 2006 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #14
    The domain name isn't needed in mod_rewrite changing URls, since it's all on the same URL. Only when you do 301 redirect.

    Is it at domain.com/.htaccess or domain.com/whatever/.htaccess
     
    Nintendo, Jan 3, 2006 IP
  15. samantha pia

    samantha pia Prominent Member

    Messages:
    4,639
    Likes Received:
    482
    Best Answers:
    0
    Trophy Points:
    310
    #15
    are you trying to redirect the whole domain to another?

    redirect 301 /anydir/index.php http://www.domain.com/index.php

    would sent people looking for that page to the other domain main page.


    so to redirect one domain to another i would have thought /index.xxx would be needed.

    redirect 301 /index.xxx http://www.domain.com/index.xxx
     
    samantha pia, Jan 4, 2006 IP