Moving Pages

Discussion in 'Programming' started by Sushi_Master, Oct 2, 2008.

  1. #1
    Hi,

    I'm about to reshuffle the content on a large coldfusion website. This will mean that most pages will move into new directories.

    We have a lot of people linking into our pages and I don't want to break these links.

    Is there any way of detecting the old URL of a page a redirecting them to the new URL?

    Thanks in advance for any help and advice.

    Sam.
     
    Sushi_Master, Oct 2, 2008 IP
  2. robhustle

    robhustle Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are a lot of strategies. Here are two.

    Method 1: Missing Template Error Handler

    1. Go to Coldfusion Administrator -> Server Settings -> Settings
    2. Scroll down to "Error Handlers" and define a missing template error handler
    3. Create the error handler you defined in step 2

    Okay, now your missing template error handler will get called any time there is a 404 error on the site. You can then parse out the error and redirect the person to the right page based on the page they were trying to access.

    This method will redirect AFTER they have thrown the 404. So, the error happens, then the person is redirected.

    Benefit -> only runs when needed.
    Drawback -> throws the error


    Method 2: Parse the URLS in application.cfc

    1. In the application.cfc, parse out the request and determine the url that they are trying to reach
    2. Analyze the url and see if they are going to a page that is in the old format / location.
    3. If they are, redirect them to a page in the new format / location.

    Benefit -> No error is thrown
    Drawback -> Executes every time

    Both methods are fairly trivial and should not take more than 15 minutes to implement. I did this for a site with over 17,000 pages and there was no problem at all.

    I would say as a follow up, make sure to monitor your site using google webmaster tools to make sure that your pages are actually being redirected properly. Any pages not properly redirecting will show up in the report.
     
    robhustle, Oct 7, 2008 IP
  3. Sushi_Master

    Sushi_Master Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the knowledge Rob, very much appreciated.
     
    Sushi_Master, Oct 30, 2008 IP