.htaccess advice needed

Discussion in 'Site & Server Administration' started by Jez, Nov 6, 2007.

  1. #1
    Hi,

    I am currently switching scripts on a directory that I own and want your advice on the best way to redirect the old pages to the corresponding new (or just to the main index might do if nothing else) There are about 2,500 existing .html pages to redirect to about the same number of .php pages. There are only a few inner pages that have links to them and I probably would not bother about a redirect at all but for the fact that google takes so long to drop old cache pages and replace with new.

    Hope someone can advise.

    Thanks.
    Jez.
     
    Jez, Nov 6, 2007 IP
  2. garbageman

    garbageman Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If your files that were in directory1 are in directory2, put this in directory1's .htaccess

    RewriteEngine on
    RewriteRule ^(.*)$ /directory2/$1 [R,L]

    That will show a redirect. To have a silent redirect, remove the "R" in brackets
     
    garbageman, Nov 6, 2007 IP
  3. Jez

    Jez Well-Known Member

    Messages:
    532
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    138
    #3
    Thanks for your reply garbageman.

    Let me just clarify how the files are atm

    The site is running on the old script which generates .html pages in the public_html folder. I have set up another script to run alongside it (just to get it working and looking right) in a sub folder of public_html called wsn. I think that's what you said but i just wanted to check with you before I possibly make a terrible mistake if I have misunderstood you :)

    I appreciate your help.

    Jez.
     
    Jez, Nov 7, 2007 IP
  4. garbageman

    garbageman Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    To redirect file(s) /* to /wsn/* without creating an infinite loop, use this as the .htaccess. (As long as the folder /wsn/wsn doesn't exist)
    
    RewriteEngine on
    RewriteRule ^([^w][^s][^n].*)$ /wsn/$1 [R,NC,L]
    
    Code (markup):
     
    garbageman, Nov 10, 2007 IP