Market Data Analyst (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume

Building Dynamic Pages With Search Engines in Mind
When I first wrote this column back in January 1999, I had no clue that it was going to be so wildly popular, and I had even less of a clue that PHPBuilder was going to take off and become as widely-used as it is today.
Since this topic seems to be so important to a wide range of developers, I'll revisit it in more detail, sharing more bits of code with you.
Almost any developer knows that search engine placement is critical to the success of a web site. What many people don't know is that a lot of search engines cannot index many database-driven pages (basically any page with a '?' or '&' in the URL).
So when I set about building gotoCity.com, one of my goals was to make the site database-driven, but still indexable. I didn't want any use of cookies or mile-long URLs, and I wanted useful, context-sensitive meta tags to be generated from every page quickly and with no effort on my part. More importantly, the method shown here actually works. My Gotocity.com web site was getting up to 150,000 page views per day just from search engines alone. That's more than enough to crush a web server.
To pull this off, I started with a subtle Apache feature that can "force" a script to be called for any certain directory tree. In my case, I wanted all URLs that fall under "/local/" to call a script. This would be MUCH easier than creating 200,000 localized web pages and a genuine directory structure to match it.
So in Apache's httpd.conf file, I added the following lines:
<Location /local>
ForceType application/x-httpd-php3
</Location>
This forces every request that starts with "/local/" to call a script called "local" (just "local", not "local.php3") in the $DOCUMENT_ROOT (usually called "/htdocs/") of your server. "local" then uses PHP to parse the URL and act accordingly. The code for my "local"" script is on the last page of this article. You can of course replace "local" with any filename you want, as long as you change your httpd.conf accordingly.
Now if you don't have access to your httpd.conf file, you can also try the <files > directive in a .htaccess file. Hundreds of people ran into this stumbling block in the past 16 months. It appears that this method only works on Linux, as people are reporting trouble on FreeBSD and Windows. If you find an .htaccess solution on Windows, let me know.
Sample .htaccess file:,/div>
<Files local>
ForceType application/x-httpd-php3
</Files>
[ Next Page ]


Comments:
Help me build a search engine on my webpagesdonflame05/18/08 23:07
which URL best for SEOi-Quickweb04/28/07 02:52
RE: Premature end ot script headersMuhammad Adeel07/30/05 15:05
Google and dynamic pagesGraham Bond07/05/05 12:35
Justin is wrongDaryll Hargraves05/12/05 15:49
SEARCH ENGINES CAN SEARCH .php?=& pages now!!Justin Halsall01/18/05 08:53
Better MethodTim 06/29/04 19:10
Re: A better way of doing (that works)Tyler Rooney03/13/04 20:05
RE: Works with Apache 2.0.xManjit01/09/04 02:59
RE: Suggestionpetre05/27/03 13:20
Fix for IIS 5Max12/22/02 10:32
RE: Any luck with Latest Apache Builds?Marc10/11/02 07:53
Suggestiondmitry10/04/02 03:56
Access Statistic?fab08/22/02 09:35
a much easyer way for shoreGeorge08/03/02 16:49
Works with Apache 2.0.xRaven07/22/02 11:09
RE: Any luck with Latest Apache Builds?Raven07/16/02 13:07
RE: Any luck with Latest Apache Builds?Raven07/16/02 11:29
RE: Any luck with Latest Apache Builds?Jason Reid07/14/02 03:54
Any luck with Latest Apache Builds?Raven07/12/02 16:02
RE:send php output directly to printerjagadish nayak07/08/02 10:41
Mod Rewrite on windows SolutionEdward Hermanson06/29/02 19:11
RE: Breaks with Apache 2?speedmax06/16/02 18:48
RE: Breaks with Apache 2?Alex Davies06/10/02 16:30
Breaks with Apache 2?a.h.s. boy06/10/02 13:02
IMPORTANT for WINDOWS usersAlex Davies06/09/02 10:53
Look back referencesTom Jurgens06/06/02 10:38
RE: google and phpStephane05/31/02 18:16
RE: Does this work for multiple files?Wahyu Harsono05/26/02 12:12
latest with FreeBSD Gunther05/12/02 22:29
how to create search engine like yahoo aden05/12/02 07:49
google and phpLimouzy L.05/11/02 21:27
RE: Any info on passing Session IDs via URL?David McInnis05/07/02 16:26
RE: Fine... What engines will get as far as .php?John G05/04/02 00:49
RE: Any info on passing Session IDs via URL?Deon Groenewald04/11/02 15:04
Google & phpLimouzy04/08/02 07:25
YES, we can use .htaccess on Windows too!!Saurabh Kumar04/04/02 13:47
Mod-Rewrite allowed at most WebhostsEdward Hermanson04/02/02 20:32
Problem with numbers?Rick04/02/02 10:41
RE: Sorry to prick your balloon, but...Razzbar03/31/02 19:30
Combined mod_rewrite solutionDavid Cross03/30/02 04:50
RE: A better way of doingDavid Cross03/29/02 11:02
RE: Sorry to prick your balloon, but...David Cross03/28/02 15:07
RE: ConvolutedDavid Cross03/28/02 14:43
RE: Sorry to prick your balloon, but...gekido03/25/02 18:38
RE: Sorry to prick your balloon, but...David Cross03/24/02 04:11
anyone know a solution for IIS?olinux03/20/02 11:35
RE: mod_rewriteMarshall03/17/02 20:09
RE: Got it working but css is not working now.DrTebi03/11/02 02:10
Sorry to prick your balloon, but...Ben03/09/02 18:58
RE: No renaming of PHP scriptsdibby03/06/02 20:14
Just make it cacheable!crimaniak02/27/02 22:30
No renaming of PHP scriptsjerry02/16/02 08:46
Files technique breaks with -DirectoryIndexjerry02/16/02 08:32
Pls I need some helpGerasimos Solomos02/05/02 08:43
ConvolutedTom Bourree01/21/02 11:26
windows .htaccess methodAndrew01/04/02 14:38
how to retrieve http header?speedyop12/29/01 13:04
HEEEELLLP :-(David Rama12/12/01 19:19
Does this work for multiple files?Avishai12/12/01 12:17
RE: Got it working but css is not working now.Frank12/05/01 16:29
Got it working but css is not working now.Frank12/05/01 13:59
Where is code fo rthe local script?Frank12/05/01 10:22
RE: How to do this with PHP as CGI?Andy11/26/01 09:03
So let me get this straight...Billy11/11/01 12:59
This could work nicely...Joerg11/07/01 07:04
RE: Updated ImprovementSander10/07/01 10:30
....and the search engine?julian10/03/01 12:03
RE: CGI error & PHP & IIS5basuq09/19/01 00:57
Simple Windows/Apache FixLux09/15/01 21:21
Good working example...Andrew09/15/01 18:21
A better way of doingDirk Engels09/05/01 11:39
running .cgi files on pws 4 harmeet singh08/31/01 18:58
Web Server AccessAlex Davies08/31/01 10:16
RE: Fine... What engines will get as far as .php?James Long08/28/01 08:18
RE: How to do this with PHP as CGI?Mark 08/27/01 15:43
RE: Way more simple way to do this!C Bullock08/15/01 18:49
RE: How does httpd.conf know to run local?dngu04708/09/01 20:33
RE: Any info on passing Session IDs via URL?Shaun Dodimead08/06/01 09:38
RE: Any info on passing Session IDs via URL?avishai08/04/01 09:09
RE: CGI error & PHP & IIS5Avishai08/03/01 21:17
connectivitysubash .k.j07/22/01 20:51
Got it to run with PHP as CGIDario Gomes07/21/01 15:39
RE: FIXED: Search engines wont index 404 pagesDavid Barrington07/20/01 17:13
Updated ImprovementSteve Warwick07/15/01 18:10
Not forcing the typeAlan Meadows07/11/01 12:46
Virtual HostRodney Chupp07/10/01 21:41
RE: .htaccess hintMattias Johansson07/01/01 03:23
What if you have session_idmark balogh06/26/01 12:08
Combining ForceType with UserDir ?EdHoo06/19/01 21:30
Fine... What engines will get as far as .php?Robert Betts06/16/01 17:17
Any info on passing Session IDs via URL?Michael Goddard06/11/01 10:23
Code snippet you might find usefuljamie05/14/01 10:33
.htaccess hintFrollen05/03/01 13:11
RE: Has anyone been spidered using this technCayley04/30/01 17:12
How to do the same for the root directory?jamie04/26/01 06:12
Premature end ot script headersShaun Mitchell04/19/01 12:10
How does httpd.conf know to run local?Shaun Mitchell04/18/01 15:54
CGI error & PHP & IIS5BAYHAA04/16/01 15:08
Has anyone been spidered using this techniqueBarrie 04/10/01 17:58
What is *.php filePrashant04/10/01 06:48
Interference from auto_prepend?Joe Sheble03/27/01 13:21
Should we fear search engine spiders?Dave Van Camp03/20/01 00:31
Does this works on IIS5?Sorin02/24/01 16:04
How to do this with PHP as CGI?Jan Krueder02/19/01 00:32
How to get it workingBazza02/14/01 09:22
Way more simple way to do this!Steve Warwick02/10/01 10:43
Where can I find httpd.conf & .htaccess filesSurajit02/09/01 02:09
RE: Different way, works on Win32 too!Keegan Miller02/08/01 14:58
can sql result be saved for next page use?Peter02/04/01 12:15
I found ErrorBard01/30/01 11:04
.htaccessBard01/30/01 11:00
Different way, works on Win32 too!Sander01/24/01 10:50
How search engines worktstow01/22/01 23:47
Got it working with PHP-NUKEDerek Musselmann01/15/01 04:39
RE: A better way... even works in windoze!Jacob Singh01/11/01 12:00
How do I get this to work with Php Nuke?Johnny01/04/01 13:59
PHP4 and MySQL search formCesar Hernandez01/03/01 11:55
Please explain moreanonymous01/02/01 11:38
a different solutionrob01/02/01 10:25
RE: 404 Method - parsing POSTR.K. Stephenson12/28/00 16:24
404 Method - parsing POSTMatt W12/21/00 01:51
RE: Will not parse query string, FATAL ERR.Elmar Bransch12/17/00 20:28
Will not parse query string, FATAL ERR.Jacob Singh12/15/00 01:21
RE: ExampleKoos van den Hout12/11/00 10:36
RE: Apache directives are unnecessaryWorldMaker12/10/00 19:00
ExampleSophie Vienne-Mattoug12/06/00 05:05
Problem w/ PHP as CGIDoug12/04/00 23:24
Typo?? httpd.conf = access.confLance12/04/00 00:43
RE: Apache directives are unnecessaryD Robinson12/03/00 12:38
A better way... even works in windoze!Josh Johnson11/26/00 15:22
RE: Dir 'local' & script file 'local'...How?Tim Perdue, PHPBuilder.com11/24/00 23:03
Got it working!Andrew11/19/00 01:49
Dir 'local' & script file 'local'...How?Doug11/08/00 10:18
Apache directives are unnecessarybrad11/07/00 21:43
RE: not really know what is it.....Mike11/03/00 03:47
apache/virtual host/htaccessIan Shannon10/31/00 10:38
RE: not really know what is it.....Arien10/29/00 04:53
not really know what is it.....Mike10/27/00 06:41
RE: Fatal error!mocha10/26/00 01:36
Fatal error!Andrew10/19/00 20:12
RE: More specific example pleasemocha10/19/00 02:55
SSI indexing by search enginesDiego Barajas10/18/00 01:29
RE: what am i doing wrong?David Cross10/02/00 03:12
what am i doing wrong?myles hocking09/27/00 12:36
RE: And if the user misses the trailing slash?Van09/24/00 14:30
And if the user misses the trailing slash?David Cross09/24/00 08:37
RE: I dont understand!!!David Cross09/24/00 06:38
More specific example pleaseDavid Cross09/24/00 06:31
another method for the configVan09/24/00 02:00
How do I get this to work in Windows?David West09/19/00 10:29
I dont understand!!!philg09/19/00 09:37
FIXED: Search engines wont index 404 pagesJosh Davidson09/12/00 23:37
SolarisWincent Colaiuta09/04/00 11:32
It does not workGerardo Garcia08/24/00 12:16
RE: Using with virtual hostsMarc Antony Vose08/09/00 08:36
Using with virtual hostsMarc Antony Vose08/09/00 08:32
RE: Image links break...Bruce Christensen08/08/00 12:26
Search engines wont index 404 error pagesSammy Hayes08/04/00 18:44
...and two more questionsa.h.s. boy07/27/00 02:57
Image links break...a.h.s. boy07/27/00 02:51
Can this technique be extended?Kieran Sexton07/20/00 13:46
mod_rewriteDave Cross07/11/00 03:25
More specific examples pleaseDave Cross07/11/00 03:24
Can't get it running ... any help out there?David Levy07/10/00 15:50
GetImageSizeAlex Ramos07/06/00 21:14
FreeBSD/ForcetypeNick may07/02/00 21:30
RE: IIS - using path info insteadIan Evans07/01/00 23:58
RE: IIS - using path info insteadIan Evans07/01/00 23:39
IIS - using path info insteadIan Evans07/01/00 13:34
RE: Example ........Amita Jalla07/01/00 05:04
RE: Example ........Tim Perdue, PHPBuilder.com06/30/00 10:11
Example ........Duncan Fordyce06/30/00 08:29
 

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.