[WEB4LIB] How to make PHP pages search engine friendly

Thomas Dowling tdowling at ohiolink.edu
Fri Jul 30 16:20:06 EDT 2004

David Moore wrote:

> I am attempting to create some dynamically generated web pages using PHP
> (with an mySQL database in the backend) for our library research guides,
> etc, but I want to make them search engine friendly. It is my understanding
> that the url cannot have ? and & characters, but I need to replace them with
> slashes. 

You may want to confirm that understanding before rewriting your 
scripts.  In my logs, I see bots from Google, Yahoo, and MSN all happily 
crawling URLs with query strings, and I see corresponding hits in search 
results.  It's also a non-issue with the SWISH-E spider we use for our 
site search.

> I have found a few web pages that explain how to do this using
> $path_info, etc., but I'm not having much luck with it. I have PHP loaded on
> a Windows 2000 server.

Instead of "...script.php?var1=Alice&var2=Bob&var3=Carol" you'd have 
"...script.php/Alice/Bob/Carol" and split the $_SERVER[PATH_INFO] 
environment variable on the "/" character.  You may have more sensible 
results if you strip off the leading slash first:

   $foo = ereg_replace("^/", "", $_SERVER[PATH_INFO]);
   list ($var1, $var2, $var3) = explode("/", $foo);

Thomas Dowling
tdowling at ohiolink.edu

More information about the Web4lib mailing list