|
Building Dynamic Pages With Search Engines in Mind
<?php
/*
Sample URLs:
/local/2/us/IA/a/50613/apartment/ - apartments in Cedar Falls, IA
/local/2/us/IA/a/ - group of cities in Iowa
/local/2/us/ - States in the US
/local/1/us/IA/a/50301/ - Des Moines City.net
*/
$url_array=explode("/",$REQUEST_URI); //BREAK UP THE URL PATH
// USING '/' as delimiter
$url_affil_num=$url_array[2]; //Co-Branding info
$url_country=$url_array[3]; //Which Country?
$url_state=$url_array[4]; //Which State?
$url_alpha_state=$url_array[5]; //Cities starting with a-g
$url_zip=$url_array[6]; //If present, build thispage
$url_content=$url_array[7]; //If present, build a sub-
// page for this city
/*
separate includes were designed to fetch the affiliate cobranding
and build appropriate style sheets on the fly. Data validation is
done prior to each query. If a URL is incorrect, bow out gracefully
or redirect home
*/
if($url_zip) {
/*
If present, query the Zip code database and build the page.
Inside the city.inc, we will check for which "content page" we are
building, if any.
*/
include('include/city.inc');
exit;
} elseif ($url_state) {
/*
If URL PATH ends here, query Zip code database,
selecting DISTINCT cities in this state
*/
if (!$url_alpha_state) {
$url_alpha_state='a';
}
include('include/state.inc');
exit;
} elseif ($url_country) {
/*
If URL PATH ends here, query ZIP code database,
selecting DISTINCT states for this country
*/
include('include/country.inc');
exit;
} else {
/*
must be mal-formed. Redirect to home
*/
Header( "Location: http://db.gotocity.com/local/2/us/");
exit;
}
?>
As you can see, if you break everything up into includes, and you have
a sensible hierarchy, this task is not terribly difficult. I now
have over 200,000 dynamic web pages that can be traversed by *any*
web indexing engine! The number increases proportionately with each
new affiliate (just create a new affiliate record in the affiliate
table).
Next week, I will talk about Logging. I built a sophisticated,
PHP logging and redirection engine to power this system.
I would appreciate any comments/criticisms about this article
or how my system could be improved.
--Tim
| Comments: | ||
| search engine | Emad | 05/08/05 05:36 |
| I wanna make a search engine with in my web | mahadi | 11/29/04 11:13 |
| .htaccess links | Walter Irving | 08/06/03 18:40 |
| Apache 2.0 | Matthew Rich | 06/26/03 15:20 |
| RE: Alternative using .htaccess | Hector Lecuanda | 02/07/03 03:35 |
| RE: Web Mail | Ricardo Sanchez | 10/07/02 18:33 |
| Automatic payments in PHP | pravin | 09/26/02 05:18 |
| RE: how to build a database driven site | Ashish Hareet | 09/19/02 12:43 |
| how to build a database driven site | Felix | 09/16/02 18:29 |
| Accessing textboxes and other elements in PHP | Somdutta | 08/27/02 04:56 |
| RE: Alternative w/ apache rewrite module | Herman | 07/09/02 17:37 |
| Web Mail | Ratana Ty | 06/20/02 20:46 |
| Apache 'look back' feature on Win32! | Dmitri | 06/14/02 11:02 |
| Apache 'look back' feature on Win 32? | Dmitri | 06/14/02 10:39 |
| RE: I don't have a clue how to do this | Pedro Borges | 04/05/02 18:58 |
| RE: I don't have a clue how to do this | Pam | 04/03/02 23:14 |
| RE: Alternative w/ apache rewrite module | Edward Hermanson | 04/02/02 20:27 |
| RE: I am so confused!! :( | David Cross | 04/01/02 05:01 |
| RE: Indexing dynamic URLs | David Cross | 04/01/02 05:00 |
| RE: Not working in netscape 6 | David Cross | 04/01/02 04:58 |
| RE: searcheable content | Luis Oliveira | 03/28/02 09:20 |
| RE: Alternative using .htaccess | Adrian | 03/05/02 18:00 |
| RE: Alternative using .htaccess | Adrian | 03/01/02 18:33 |
| RE: Alternative using .htaccess | Adrian | 03/01/02 18:30 |
| RE: Another source ? Apache configuration | sLeytr | 02/26/02 09:50 |
| where do i start | Mark | 02/24/02 00:24 |
| RE: Another source ? Apache configuration | Patrick | 02/21/02 05:30 |
| RE: Alternative using .htaccess | Alexander Khine | 01/22/02 22:19 |
| I use this | Mat Kovach | 01/12/02 00:31 |
| RE: Lost POST vars (javascript workaround) | Jim 'Buffallo Thrill' Peterson | 12/31/01 11:26 |
| RE: Alternative using .htaccess | Alex | 12/31/01 01:25 |
| Alternative w/ apache rewrite module | Jogn Ardeneese | 12/23/01 22:47 |
| RE: Alternative using .htaccess | Martin | 12/12/01 08:24 |
| Another source | tfp | 11/14/01 09:48 |
| I am so confused!! :( | Mark Baker | 11/08/01 16:10 |
| RE: Lost POST vars (javascript workaround) | Jim 'Buffallo Thrill' Peterson | 10/02/01 13:45 |
| Attn: Julie Hall | C Bullock | 09/29/01 03:07 |
| Indexing dynamic URLs | Peter Clemons | 08/22/01 15:41 |
| Hyper Links | William Sheets | 08/15/01 20:56 |
| RE: Question | J Hall | 07/24/01 07:33 |
| RE: Alternative using .htaccess | Shannon Thrasher | 07/10/01 11:05 |
| Not working in netscape 6 | Jeff Wells | 07/02/01 17:18 |
| RE: Lost POST vars (javascript workaround) | maxual | 05/21/01 10:25 |
| searcheable content | tiago coelho | 04/09/01 18:00 |
| Question | Nico Kanters | 04/07/01 16:50 |
| Different directory | Jason | 03/20/01 04:37 |
| RE: Alternative using .htaccess | Kevin | 02/23/01 13:55 |
| access.conf | C Casey | 02/18/01 07:41 |
| Ch@t in PHP4 | Qndre | 02/10/01 23:58 |
| Lost POST vars | Matt | 02/01/01 23:48 |
| RE: win32 error | Stephen Cook | 01/31/01 05:49 |
| search engine development... | haris khan | 01/31/01 04:07 |
| win32 error | Stephen Cook | 01/29/01 19:22 |
| Liked Difference in Idea | Anirban Dutta | 01/27/01 05:35 |
| Building the pages | Stephen Cook | 01/23/01 03:17 |
| RE: Alternative using .htaccess | Artem Shevchenko | 01/21/01 15:03 |
| RE: Alternative using .htaccess | Bard | 01/18/01 10:45 |
| Referenced article | R.K. Stephenson | 11/17/00 14:40 |
| Alternative using .htaccess | Mark Hilgart | 10/01/00 06:23 |
| Extremely useful! | Jens-Petter Salvesen | 08/31/00 16:42 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


