1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Creating a dynamic redirect in PHP

Discussion in 'PHP' started by macdesign, Sep 27, 2004.

  1. #1
    I'm not sure what the right term is, but I've created hundreds of "redirect:" pages that are place holders for content not created. These pages are created by programming, [and each one redirects to a different place] but they are uploaded as static pages.

    They are pages with

    <META HTTP-EQUIV="Refresh" CONTENT="5; URL=http:.......

    Now what I want to do is replace my custom 404 not found page for the site, with a PHP page, that will somehow pick up the URL string that the browser tried to go to, and dynamically decide what page it should go to, and create the redirect on the fly.

    Now I keep meaning to learn PHP, so I might as well start someplace. I've no idea how I find what the original target URL was.

    My concern is that if I by mistake I redirect to another page not found, then I could get caught in an endless loop.
     
    macdesign, Sep 27, 2004 IP
  2. Sholva

    Sholva Peon

    Messages:
    154
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What kind of 404's are you getting? With some examples it might be easy to see how you could dynamically redirect them to a static url.

    Btw, $_SERVER["REQUEST_URI"] should tell you what you are looking for to start with, I think. Not a PHP expert but it's not extremely difficult.
     
    Sholva, Sep 27, 2004 IP
  3. macdesign

    macdesign Peon

    Messages:
    568
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I did a quick test, and that looks like what I need to get me started. Off to read about how to parse strings in PHP. Thanks.
     
    macdesign, Sep 27, 2004 IP
  4. macdesign

    macdesign Peon

    Messages:
    568
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK, I got it working - I think. I'm just waiting for my Host to reset the default 404 page to my new PHP page.
     
    macdesign, Sep 27, 2004 IP