Problem Using PHP for Server Files Redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JDJones

    Problem Using PHP for Server Files Redirect

    We are trying to set up a PHP page to handle server requests for
    individual web pages that we are moving to a new server. The part that
    complicates this procedure is that the files will not be mirrored on the
    new server. Instead many will be residing in new directories and
    subdirectories than they were in on the old server.

    What we wanted to do was when someone requested a specific page from our
    old server, it would recognize the non-existent page and send it to the
    redirect.php page that we created. That part works fine. Unfortunately,
    PHP is unable to see what page originally was requested. I thought it
    would see one page back, but it doesn't.

    Is there any way to get the redirect.php to identify what the called for
    page was so it can redirect it forward to the place the file resides in
    on new server properly? I know this would be simple if this was from a
    form but it's not.

    Any suggestions would be appreciated.

  • Michael Fuhr

    #2
    Re: Problem Using PHP for Server Files Redirect

    JDJones <seebelow@spryn et.com> writes:
    [color=blue]
    > We are trying to set up a PHP page to handle server requests for
    > individual web pages that we are moving to a new server. The part that
    > complicates this procedure is that the files will not be mirrored on the
    > new server. Instead many will be residing in new directories and
    > subdirectories than they were in on the old server.
    >
    > What we wanted to do was when someone requested a specific page from our
    > old server, it would recognize the non-existent page and send it to the
    > redirect.php page that we created. That part works fine. Unfortunately,
    > PHP is unable to see what page originally was requested. I thought it
    > would see one page back, but it doesn't.[/color]

    Is redirect.php on the old server or on the new one? How are you
    invoking redirect.php for non-existent pages, and how did you try
    to get PHP to "see one page back"?

    Are you using PHP as an Apache module? If so, and if you added
    something like "ErrorDocum ent 404 /redirect.php" to the Apache
    configuration on the old server, then the original request should
    be available in $_SERVER['REDIRECT_URL'] and $_SERVER['REQUEST_URI'].
    [color=blue]
    > Is there any way to get the redirect.php to identify what the called for
    > page was so it can redirect it forward to the place the file resides in
    > on new server properly? I know this would be simple if this was from a
    > form but it's not.[/color]

    Do you have a reason for doing the redirects with PHP instead of
    using whatever redirect capabilities the web server has? If you're
    using Apache then you might be able to use the Redirect* directives
    from mod_alias or the Rewrite* directives from mod_rewrite.

    --
    Michael Fuhr

    Comment

    Working...