Redirect folders link content

Discussion in 'PHP' started by SoniCute, Aug 30, 2006.

  1. #1
    Guys,can let me know the code on .htaccess how redirect folder link contents,I dont know how explained this but I try give a sample.

    I have old site with path www.domain.com/forum
    Tons link on this path have been indexed by SE.

    Then I build tutorial on main page for it,let say www.domain.com/index.php
    This main page not indexed yet by SE.

    So how redirect all link on "forum" folder to this main page.Because I want disable forum folder but want use indexed link on it to driving traffic.

    So when visitor click on search result with path www.domain.com/forum/blablabalaba1 or www.domain.com/forum/blablabalaba2 they will redirect to www.domain.com/index.php
     
    SoniCute, Aug 30, 2006 IP
  2. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm, this should be quite simple, if I understand you correctly:

    RewriteRule ^forum/? http://www.domain.com/index.php [R=301]
    Code (markup):
    Any request to /forum, /forum/ or /forum/blahblahblah will be redirected to your index page. You forum will therefore cease to exist, but any traffic will be redirected as you have asked. Infact, any file that starts with the word 'forum' will also be directed, e.g. 'forum.html' or 'forumbrellas.html'.

    Cryo.
     
    Cryogenius, Aug 31, 2006 IP
  3. SoniCute

    SoniCute Active Member

    Messages:
    585
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for help,yes you are correct about my question,but when I try it,your redirect code doesnt work :D
     
    SoniCute, Aug 31, 2006 IP
  4. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Did you add the line "RewriteEngine on" to your .htaccess file? Sorry, I should have mentioned it.

    Cryo.
     
    Cryogenius, Aug 31, 2006 IP
  5. SoniCute

    SoniCute Active Member

    Messages:
    585
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Yes I have added "RewriteEngine on" before that code.
     
    SoniCute, Aug 31, 2006 IP
  6. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hmm... Can't see any reason why it wouldn't work. I assume that mod_rewrite is loaded in your config?
     
    Cryogenius, Aug 31, 2006 IP
  7. SoniCute

    SoniCute Active Member

    Messages:
    585
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #7
    do you mean mod_rewrite enable?if so yes my server support it..its okay Cryogenius,thanks for your help,try to seeking other help :D
     
    SoniCute, Aug 31, 2006 IP