Re: PHP and Search Engines

From: Date: Thu, 09 Nov 2000 17:05:29 +0000
Subject: Re: PHP and Search Engines
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-24514@lists.php.net to get a copy of this message
Hi php! On Thu, 09 Nov 2000, php@minotaur.nu wrote: > On Wed, 8 Nov 2000 11:03:18 -0800 (PST), you wrote: > > > http://www.foo.bar/some/path/script.php/arg1/arg2 > >$PATH_INFO will contain "/arg1/arg2" > >... > >This makes things very flexible for you and you can keep your URLs nice > >and pretty. I hate big long ugly untypable URLs with a passion. URLs > >should be easy to guess. For example: > > http://www.foo.bar/products/widget > >That should give me information and the product called "widget". > > I'm just finishing off a website service with a good example of just > that technique. me too :) almost done the second one, and I found it to be so cool. You can see it in action at www.isarescu.ro (an election site, yap we have that in .ro just about now), and soon at www.rav.ro. Basically I have a script, browse.php, which plays the role of a controller (in a MVC pattern), and it does PATH_INFO processing and general hooks setting. Then, in layout.php, I have defined a general template of the site. A snippet of the browse.php (just to make an idea) would be: // here we get some spicy vars $req_srv = getenv ('SERVER_NAME'); $req_me = getenv ('SCRIPT_NAME'); $req_uri = getenv ('REQUEST_URI'); $req_nfo = getenv ('PATH_INFO'); $req_rel = dirname ($req_me); // becase of the browse.php/foo/bar stuff, we must set the // real document base,for further links to work properly $L_BASE = 'http://' . $req_srv . $req_rel. '/'; $L_CONTENT_INFO = explode('/', $req_nfo); $L_CONTENT_INFO[0] = $req_nfo; /* now we have: * array ([0] => "/foo/bar", [1] => "foo", [2] => "bar") */ $req_act = $L_CONTENT_INFO[1]; $L_START_HOOK = null; $L_END_HOOK = null; $L_CONTENT_HOOK = array ('include_section', "$req_act.php"); switch ($req_act) { case 'news': include $_PHPLIB['libdir'].'rav_news.inc'; $L_CONTENT_HOOK = array ('showNews', NEWS_LONG); break; case 'prima': if (OUTPUT_CACHING) { include $_PHPLIB['libdir']. 'rav_cache.inc'; $L_START_HOOK = array ('cache_prolog', "cache/$req_act.html"); $L_END_HOOK = array ('cache_epilog', "cache/$req_act.html"); } include $_PHPLIB['libdir']. 'rav_news.inc'; include $_PHPLIB['libdir']. 'rav_virus.inc'; break; default: $page = resolve_topic ($L_CONTENT_INFO); if ($page == false) { header("Location: ${L_BASE}browse.php/prima"); exit; } else { $L_CONTENT_HOOK[1] = $page; } } //////////////[ CONTENT GENERATION ]/////////////////// if ($L_START_HOOK != null) { $L_START_HOOK[0]($L_START_HOOK[1]); } include 'layout.php'; //in it we call the content generating function if ($L_END_HOOK != null) { $L_END_HOOK[0]($L_END_HOOK[1]); } I for one, found this way of organizing thins the most productive, also given the interaction with the design guys who are too use to Dreamwaver templates :) -- teodor

« previous php.general (#24514) next »