> On Thursday 15 January 2004 02:44, Ryan A wrote:
> 
>> It seems to be partly working.
>> 
>> /*
>> How isn't it working? What happens? I would try one variable first, get
>> that working, then add the others. Also, I am not sure how it will
>> handle the space in "Beginners Corner". Try passing simple values first.
>> */
>> Its a bit hard to explain what happens so see for yourself:
>> Heres the index page:
>> http://www.rizkhan.net/articles/articles.php
>> Heres the actual page:
>> http://www.rizkhan.net/articles/show.php?category=Beginners%20Corner&sid=1&;
>> id=1 and then if you modify it to:
>> http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1
>> 
>> it just shows me the index...which even links wrong.
>> 
>> Ok, will try to pass a value without the space in between.
> 
>>>> RewriteRule ^show/(.*)/(.*)/(.*).php
>>>> /show.php?category=Beginners%20Corner&sid=$2&id=$3
> 
> It doesn't look like your rule would match. Try:
> RewriteRule ^show/(.*)/(.*)/(.*)
> 
> Another way to achieve a similar result without using Rewrite is to parse
> $_SERVER['REQUEST_URI'], and possibly $_SERVER['PATH_INFO']
> 
> Eg if your link is:
> 
> http://www.rizkhan.net/articles/show.php/Beginners%20Corner/1/1
> 
> Then $_SERVER['REQUEST_URI'] would contain
> 
> /articles/show.php/Beginners%20Corner/1/1
> 
> and $_SERVER['PATH_INFO'] would contain
> 
> /Beginners%20Corner/1/1

Ryan,

I'm doing what I believe Jason is indicating above. I'm sure in your
research you read the articles about URL rewriting on A List Apart,
specifically this one: <http://www.alistapart.com/articles/succeed/>. Using
a similar approach, I'm saving page content in a database with the unique
identifier set to the desired value of $REQUEST_URI. After redirecting all
requests to index.php as described in the article, I use code in index.php
similar to what's in the article, plus this for the database content:

-----

// check for database content
$conn = db_connect();
if (!$conn) {
    $db_error = mysql_error();
    include("error_page.php");
    exit();
}
// get the page details from db
$request = substr($REQUEST_URI, 1);
$results = mysql_query("SELECT DisplayStatus FROM Pages WHERE
MenuPath='$request' AND DisplayStatus='Y'");
if (!$results) {
    $db_error = mysql_error();
    include("error_page.php");
    exit();
}
if (mysql_num_rows($results) > 0) {
    include("page.php");
    exit();
}

// if request has not been matched, include custom error page
include("notfound.php");
exit();

-----

That pulls page content based on $REQUEST_URI. I build site menus from the
database, using values from the MenuPath field as URLs.

HTH

--
Lowell Allen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to