Hi Friend,
I have a solution considering your server or webhost supports rewrite module...
# This is the .htaccess file
# You need to append these codes in your .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php/$1 [L]
Now when you have done this, the next step is a url parsing engine... a simple example is as follow
require_once CLASS_PATH.'database.php';
require_once CLASS_PATH.'generator.php';
class URIParser {
private $uri;
private $new_uri;
private $raw_data;
function __construct()
{
$uri = trim($_SERVER['REQUEST_URI'], '/');
$this->uri = explode('/', $uri);
}
function parseUri()
{
$user = $this->uri[0];
$db = new Database();
$db->start();
$db->prepare("SELECT ID FROM * WHERE username = '?'");
$response = $db->execute(array($user));
$db->stop();
$id = $response[0]['ID'];
$this->new_url = BASE_URL."profile.php?id=".$id;
}
function display()
{
$generator = new Generator();
$generator->prepare($this->new_uri);
$this->raw_data = $generator->get();
echo $this->raw_data;
}
}
$parse = new URIParser();
$parse->parseUri();
$parse->display();
?>
This code is an abstracted example of how this can be achieved... This is not a complete code. I hope that this code has given you some idea. By the way a very simple method though is url rewrite module but this is a cool method as you have a lot of control over how to parse the url and it is a more advanced method too.... :D
With Regards
Tushar Srivastava