301 redirect help.

Discussion in 'Apache' started by aspidov, May 6, 2006.

  1. #1
    hi guys, i moved my site from root to a folder and need to redirect all search engine traffic to the right place, so what i need is this:

    When the request is site.com/any-file-name.here i want it to automaticly redirect to site.com/myfolder/any-file-name.here

    Thanks for any kind of help you can offer. I appreciate your time looking at this.
     
    aspidov, May 6, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)\.here$ http://www.domain.com/myfolder/$1.here [R=301,L]
     
    Nintendo, May 6, 2006 IP
  3. Jean-Luc

    Jean-Luc Peon

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

    I did not test it, but I think that Nintendo's suggestion will go in an endless loop from site.com/any-file-name.here to site.com/myfolder/any-file-name.here to site.com/myfolder/myfolder/any-file-name.here to ...

    I would try this:
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/myfolder
    RewriteRule ^(.*)$ /myfolder/$1 [R=301,L]
    Code (markup):
    Jean-Luc
     
    Jean-Luc, May 7, 2006 IP
  4. aspidov

    aspidov Well-Known Member

    Messages:
    2,875
    Likes Received:
    272
    Best Answers:
    0
    Trophy Points:
    175
    #4
    The code Nintendo suggested didnt work at all. The code from Jean-Luc worked perfect. Thanks!
     
    aspidov, May 7, 2006 IP