Redirect old files to homepage

Discussion in 'Apache' started by idragon, Jan 26, 2010.

  1. #1
    Hi Guys,

    I have many of the old site engine pages still in google and i want to redirect them to a specific space, for example:

    I have lots of media-XXX.html, video-XXX.html and i want to redirect them 301 to homepage.

    Can somebody help me with this?

    Thanks
     
    idragon, Jan 26, 2010 IP
  2. ibg

    ibg Member

    Messages:
    25
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    38
    #2
    This should do the trick :
    redirect 301	/pagename.html	http://www.yoursite.com
    Code (markup):
    This should be done for each page. In case all the old files have media-****.html and video-****.html format and you have no new pages that start with media or video I can give you 2 lines of code that will redirect all these pages to the homepage.
     
    ibg, Jan 27, 2010 IP
  3. idragon

    idragon Peon

    Messages:
    309
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, yes i know this process, i want to redirect a huge ammount of files, so i don't want to add too many lines in .htaccess since it will slow the Apache.

    So i want to redirect all those pages to the hompage, like you said, can you give me those lines of code?

    Thanks a lot mate
     
    idragon, Jan 27, 2010 IP
  4. ibg

    ibg Member

    Messages:
    25
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    38
    #4
    There's no way to test it here but try these:
    
    RewriteRule ^media-([^/\.]+).html$ http://www.yoursite.com/ [L,R=301]
    RewriteRule ^video-([^/\.]+).html$ http://www.yoursite.com/ [L,R=301]
    
    Code (markup):
    The code above would depend on the XXX content - if it's numbers and letters only etc.
     
    ibg, Jan 27, 2010 IP
    idragon likes this.
  5. idragon

    idragon Peon

    Messages:
    309
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks mate, it works!
     
    idragon, Jan 27, 2010 IP