Redirect 145,000 pages

Discussion in 'PHP' started by HomeComputerGames, Jun 4, 2009.

  1. #1
    It was recently brought to my attention about my site's terrible URL structure......and I agree. It is something I have been meaning to correct since I started the site. Later I procrastinated out of fear of losing what I have.

    I wrote a system to make hard copies of all of my dynamic pages.
    I have the room and it only updates when the page is edited.
    A little disk space is worth the mysql lag some of my large categories have.
    This works well and the database lag is removed.
    I just have a fear of initiating it due to SERPS loss,

    So can you please advise on What would be the best way to redirect a large dynamic site so no negative effects are felt?

    Would the proper way be for me to insert code into the dynamic pages header?
    I concatenate the category and title of the page and append it to "http://www.new-url.com/" the same way the files are created and then redirect via the header.

    Is this Google Friendly?

    <?
    if($_SERVER['QUERY_STRING']){
    $NewPath = str_replace (" ", "-", $PageCategory).'/'.str_replace (" ", "-", $PageTitle).'php';
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Status: 301 Moved Permanently" );
    header( "Location: http://www.new-url.com/{$NewPath}");
    exit(0);
    }
    ?>
     
    HomeComputerGames, Jun 4, 2009 IP
  2. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    MOD_REWRITE is the way to go
    would not use a php file for this
     
    atlantaazfinest, Jun 4, 2009 IP
  3. HomeComputerGames

    HomeComputerGames Peon

    Messages:
    871
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have heard this but not sure how I would pull the information that I need for the redirect.
    I understand the pattern matching
    Certainly I cannot post 145,000 rules though ?
     
    HomeComputerGames, Jun 4, 2009 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    You best bet is to do as you suggested and dynamically redirect each page. A mod_rewrite script would not be possible if you need to pull info from a database to get the proper destination page.

    I would also do one of the following, to reduce the normal load on the server. Either use a front-end caching systems, so that once a page is called, it will be further called from the cache. Or, write a script to write all of the pages you need redirected to make them completely static without any database calls. This would eliminate the further RAM load you would experience with caching all of the pages.
     
    jestep, Jun 4, 2009 IP
  5. Hoth

    Hoth Well-Known Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    Any 301 redirect should be google-friendly. Google doesn't really know or care if you're using .htaccess or PHP to do it.
     
    Hoth, Jun 4, 2009 IP
  6. HomeComputerGames

    HomeComputerGames Peon

    Messages:
    871
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks All, it is greatly appreciated.
    I imagine a few test pages should be tried first to insure Google doesn't slap me.
     
    HomeComputerGames, Jun 5, 2009 IP
  7. jhbalaji

    jhbalaji Well-Known Member

    Messages:
    1,474
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #7
    My best advice is to go wit .htaccess and MOD_REWRITE mate...
     
    jhbalaji, Jun 8, 2009 IP