Posted: Wed Sep 05, 2007 12:11 am
It does work, you just have to set up your own url mapping scheme.
For example if you had the url http://www.example.com/games/play/37/some-game
Now you have every part of your URL into an array. Which you could then map to games.php?action=play&gameid=37
You don't need to have the .php extension in your URL, and you don't need to use .htaccess.
Let's choose a much simpler URL /articles/1357
For example if you had the url http://www.example.com/games/play/37/some-game
Code: Select all
$parts = explode('/', $_SERVER['PATH_INFO']);You don't need to have the .php extension in your URL, and you don't need to use .htaccess.
Let's choose a much simpler URL /articles/1357
Code: Select all
$parts = explode('/', $_SERVER['PATH_INFO']);
//check if the first part exists.. we can add the .php on here
if (file_exists($parts[0] . '.php'))
{
$str = 'articles.php';
//do some querying or something to check if $part[1] (1357 in the example, is a valid article id
if ($is_valid_article_id)
{
$str .= '?id=' . $parts[1];
//redirect to page, or include() page, or whatever
header('Location: http://www.example.com/' . $str);
exit;
} else
{
header('Location: http://www.example.com/articles.php');
exit;
}
} else
{
header('Location: http://www.example.com');
exit;
}