|
Posted by "Andras Kende" on 10/21/21 11:21
-----Original Message-----
From: Terry Romine [mailto:terry_romine@earthlink.net]
Sent: Thursday, July 14, 2005 3:52 PM
To: php
Subject: [PHP] 404 Not Found -> refresh to directory
I have a website that has several hundred agents in a mysql database. The
client wants to be able to enter the domain.com/agentname and be redirected
to a standard page where we show the agent information. An example would be
an agent named John Smith whose agentname would be jsmith. So the user would
enter domain.com/jsmith and get the agent's profile.
I tried initially to dummy up a 404 page, where if the link was like:
domain.com/jsmith that it would parse the agent name and pass it through to
domain.com/agent_profile.php?agent=jsmith. It failed to work, ending up with
a recursive call to the 404 page and getting hung.
Right now, I have directories set up for each agent, with an index.php that
does the redirect. It's really getting to be a mess with so many
directories.
I need to be able to check the mysql database for the agent name, and if
found, do a redirect (header("Location: agent_profile.php?agent=agentID")
and if not, continue to a standard 404 error page, or a "sorry not found"
page.
I think my question is: is there an easy way to use a 404 page written in
php to capture the parameters from the missing page request and test against
a db, resulting in either a valid page redirect or a not found redirect?
Terry
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
..htaccess:
RewriteEngine on
RewriteRule ^([\w-]+)$ index.php/$1
index.php:
<?php
$uriparams = explode("/",$REQUEST_URI);
$uriparams = explode("?",$REQUEST_URI);
$agent = $uriparams[0];
$agent = eregi_replace("/","",$agent);
// Select from mysql where agent = agent etc.. etc..
echo ("Location: agent_profile.php?agent=".$agent);
?>
Best regards,
Andras Kende
http://www.kende.com
Navigation:
[Reply to this message]
|