Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

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

[Page 1]  [Page 2]  


Comments:
search engineEmad05/08/05 05:36
I wanna make a search engine with in my webmahadi11/29/04 11:13
.htaccess linksWalter Irving08/06/03 18:40
Apache 2.0Matthew Rich06/26/03 15:20
RE: Alternative using .htaccessHector Lecuanda02/07/03 03:35
RE: Web MailRicardo Sanchez10/07/02 18:33
Automatic payments in PHPpravin09/26/02 05:18
RE: how to build a database driven siteAshish Hareet09/19/02 12:43
how to build a database driven siteFelix09/16/02 18:29
Accessing textboxes and other elements in PHPSomdutta08/27/02 04:56
RE: Alternative w/ apache rewrite moduleHerman07/09/02 17:37
Web MailRatana Ty06/20/02 20:46
Apache 'look back' feature on Win32!Dmitri06/14/02 11:02
Apache 'look back' feature on Win 32?Dmitri06/14/02 10:39
RE: I don't have a clue how to do thisPedro Borges04/05/02 18:58
RE: I don't have a clue how to do thisPam04/03/02 23:14
RE: Alternative w/ apache rewrite moduleEdward Hermanson04/02/02 20:27
RE: I am so confused!! :(David Cross04/01/02 05:01
RE: Indexing dynamic URLsDavid Cross04/01/02 05:00
RE: Not working in netscape 6David Cross04/01/02 04:58
RE: searcheable contentLuis Oliveira03/28/02 09:20
RE: Alternative using .htaccessAdrian03/05/02 18:00
RE: Alternative using .htaccessAdrian03/01/02 18:33
RE: Alternative using .htaccessAdrian03/01/02 18:30
RE: Another source ? Apache configurationsLeytr02/26/02 09:50
where do i startMark02/24/02 00:24
RE: Another source ? Apache configurationPatrick02/21/02 05:30
RE: Alternative using .htaccessAlexander Khine01/22/02 22:19
I use thisMat Kovach01/12/02 00:31
RE: Lost POST vars (javascript workaround)Jim 'Buffallo Thrill' Peterson12/31/01 11:26
RE: Alternative using .htaccessAlex12/31/01 01:25
Alternative w/ apache rewrite moduleJogn Ardeneese12/23/01 22:47
RE: Alternative using .htaccessMartin12/12/01 08:24
Another sourcetfp11/14/01 09:48
I am so confused!! :(Mark Baker11/08/01 16:10
RE: Lost POST vars (javascript workaround)Jim 'Buffallo Thrill' Peterson10/02/01 13:45
Attn: Julie HallC Bullock09/29/01 03:07
Indexing dynamic URLsPeter Clemons08/22/01 15:41
Hyper LinksWilliam Sheets08/15/01 20:56
RE: QuestionJ Hall07/24/01 07:33
RE: Alternative using .htaccessShannon Thrasher07/10/01 11:05
Not working in netscape 6Jeff Wells07/02/01 17:18
RE: Lost POST vars (javascript workaround)maxual05/21/01 10:25
searcheable contenttiago coelho04/09/01 18:00
QuestionNico Kanters04/07/01 16:50
Different directoryJason03/20/01 04:37
RE: Alternative using .htaccessKevin02/23/01 13:55
access.confC Casey02/18/01 07:41
Ch@t in PHP4Qndre02/10/01 23:58
Lost POST varsMatt02/01/01 23:48
RE: win32 errorStephen Cook01/31/01 05:49
search engine development...haris khan01/31/01 04:07
win32 errorStephen Cook01/29/01 19:22
Liked Difference in IdeaAnirban Dutta01/27/01 05:35
Building the pagesStephen Cook01/23/01 03:17
RE: Alternative using .htaccessArtem Shevchenko01/21/01 15:03
RE: Alternative using .htaccessBard01/18/01 10:45
Referenced articleR.K. Stephenson11/17/00 14:40
Alternative using .htaccessMark Hilgart10/01/00 06:23
Extremely useful!Jens-Petter Salvesen08/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.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.