By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

Problem Using PHP for Server Files Redirect

P: n/a
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.

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JDJones <se******@sprynet.com> writes:
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 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 "ErrorDocument 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'].
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.


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
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.