Gossamer Forum
Home : General : Internet Technologies :

Custom Error 404 and PHP

Quote Reply
Custom Error 404 and PHP
I have a file (index.php) which handles all pages of my site. One page is index.php/?404 which calls a custom Error 404 page. Apache 2.0 is configured properly and when someone enters a 'bad' url, they are redirected to index.php/?404 with no problems. What I would like to do though is set a variable on the error page with the name of the page they entered (the bad url), but I cannot get that to work. Any input?

What I want to do is create a list of short cuts on the error page so that a "common sense" url could be converted to the actual url. Example. There could be a page called index.php/?432/39.1/45 which is a section on dogs. If a user were to input mysite.com/dogs the script would detect the word dogs and redirect to ?432/39.1/45. Make sense?

It all boils down to how to populate a variable on a custom error page with the requested page. I have tried $SERVER[REDIRECT_URL] and $REDIRECT_URL, and neither way is the variable populated.

Is there hope?
Quote Reply
Re: [Lee] Custom Error 404 and PHP In reply to
Try REQUEST_URI
Quote Reply
Re: [Jarrod] Custom Error 404 and PHP In reply to
I tried REQUEST_URI, but that only returns the query of my index page ... /?404

hmmmm
Quote Reply
Re: [Lee] Custom Error 404 and PHP In reply to
Try:

REDIRECT_URL
Quote Reply
Re: [Lee] Custom Error 404 and PHP In reply to
Initially tried REDIRECT_URL (see initial posting), but didn't work.
Quote Reply
Re: [Lee] Custom Error 404 and PHP In reply to
I think its a dead end question. I tried doing this a while ago (tried it in both PHP and Perl), but couldn't seem to get a full string (which is really what I was after). I ended up just giving an error message.

This is all I ended up using to find out the requesting page;

Code:
if (preg_match("/formmail/i" ,$_SERVER['REQUEST_URI'])) {
$suggestions .= "<a href=\"http://new.ace-installer.com\">Ace FormMail</a><BR>";
}

.. but, as I guess you know, it won't pass on the /?404 part Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Custom Error 404 and PHP In reply to
Thanks Andy ... at least I know I wasn't the only one who couldn't get it to work now.

Hmmmm, wonder if I could set a cookie and pass that info somehow?