httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blomstrom <>
Subject Re: [users@httpd] Re: Mod-Rewrite: Changing + to -, _ or .
Date Tue, 23 Aug 2005 18:49:16 GMT
--- John Hicks <> wrote:

> David Blomstrom wrote:
> > OK, I've finally got it working. Thanks for all
> the
> > tips, everyone.
> Would you mind sharing with us just how you solved
> your problem? (Future > generations may thank you.)

Sorry, I didn't see your post until just now - and I'm
not even sure if I can answer your question! This is
still kind of confusing for me, and my fix may not
have been a complete fix. But I'll try.

First, go to The links in the
gray area near the top of the page are static links
that I inserted manually. There are no PHP functions
or mod_rewrite rules associated with them.

But just below that on the left side of the page is
the linked word Topics. Click it, then choose Home,
then click Biomes, then Tundra, then Tundra Mammals,
and you'll wind up at this link:

Notice that the bread crumb links at the top of the
page displays this:

GeoZoo > Topics  >  Home  >  Biomes  >  Tundra  >
Tundra Mammals it should. But the URL features a +, which I
want to get rid of:

On my LOCAL site, I'm now using this mod_rewrite rule:

RewriteRule ^topics/([-a-zA-Z]+)/?$
topics/index.php?topic=$1 [L]

That changes the URL to this:


However, it kills my bread crumbs script, which
displays this:

GeoZoo > Tundra-Mammals

...instead of:

GeoZoo > Topics  >  Home  >  Biomes  > Tundra > Tundra

It works fine as long as every database value (or link
segment) consists of just one word. For example, the
URL http://geozoo/topics/tundra is complemented with
this link string:

GeoZoo > Topics  >  Home  >  Biomes  > Tundra

I posted that page's HTML - that is, for my LOCAL page
- at the end of this post, though it may be a lot to
wade through. But here's a key line:

// If you replace + with - in .htaccess, insert this
$Display = str_replace('+', '-', $Display);

I'm not working on, which
presents another problem. So far, all my database
table cells contain just one word, but when linking to
species, I want to combine words from two FIELDS.
After all, species names consist of a genus name + a
species name, as in Canis lupus or Homo sapiens.

So instead of "Tundra Mammals" (derived from one
cell), I now have "Canis lupus" (derived from two
cells). Besides changing the linking physically - to
Canis_lupus, for example - I have to somehow let the
database know that "Canis_lupus" means fetch
information from the row where the field Name is lupus
AND the field Parent is Canis.

As you can see, my notes are probably too confusing to
benefit anyone on this list. And I haven't even
mentioned my other plot: Offering visitors a PHP
function that lets them toggle between lists of
scientific names and common names. :)

* * * * *

<?php echo "<?xml version=\"1.0\"
encoding=\"iso-8859-1\"?".">"; ?>
<html xmlns="">
<title><?php $_GET['topic'] ?></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
include ($_SERVER['DOCUMENT_ROOT']."/doctype.php");
$path = '' . $_SERVER['DOCUMENT_ROOT'] . '';
$myID = 'stacks';
$mycode = $_GET['topic'];
$mysection = 'topics';
$mychannel = 'adults';
<link href="/a1/css/aaa.css" rel="stylesheet"
<link href="/a1/css/stacks.css" rel="stylesheet"

<div id="divtop">
<br /><br /><br /><br /><br /><br />
$_GET[topic] = str_replace('-', ' ', $_GET[topic]);
echo '<div><h1>' . $_GET[topic] . '</h1></div>
<div class="subtitle" style="font-weight: 800; color:
#f00;">(This section is obviously under construction.
<div id="kidstacks">(<a href=/kids/<?php echo
$_GET['topic'] ?>>Kids version</a>)</div>
<br />

<div id="toplinks">
$stringToExplode = 'Temperate-Conifer-Forests';
$arrayExploded = explode('-', $stringToExplode);
$stringToShow = implode(' ', $arrayExploded); 

<a href="/"><img style="position: relative; top: 5px;"
src="/images/icons/logo.gif" width="100" height="30"
/></a> &gt;<?php
function display_children($parent, $level)

$result = mysql_query('SELECT Name, Name2 FROM
gztopics as GZT WHERE Parent="' . $parent . '";');
   while ($row = mysql_fetch_array($result)) {
       echo str_repeat('  ',$level).$row['Name']."\n";
       display_children($row['Name'], $level+1);
function get_path($node) {
   $result = mysql_query('SELECT Parent FROM gztopics
'. 'WHERE Name="'.$node.'";');
   $row = mysql_fetch_array($result);
   $path = array();
   if ($row['Parent']!='') {
       $path[] = $row['Parent'];
       $path = array_merge(get_path($row['Parent']),
   return $path;

$mypath = get_path($mycode);
$$mypath[$i] = str_replace(' ', '-', $$mypath[$i]);
echo "<a href=\"".$mypath[$i]."\"> ".$mypath[$i]."
</a>  &gt; ";
<span class="navhere" style="border: none;"><?php echo
$_GET['topic'] ?></span>
<div class="topsections">
<span id="toptop"><a
<span id="topworld"><a href="/world/">World</a></span>
<span id="topref"><a
<span id="topglos"><a
<span id="topcal"><a
<div class="topsections">
<span id="topabout"><a href="/about/">About
<span id="topcontact"><a

<div style="background: #eee; text-align: center;
border: 1px solid #000; border-left: none;
border-right: none;">
<strong>Main Topics:</strong> <a
href="/topics/Home">Animal Homes</a> | <a
href="/topics/Appearance-and-Anatomy">Appearance &amp;
Anatomy</a> | <a href="/topics/Senses">Senses</a><br
<a href="/topics/Locomotion">Locomotion</a> | <a
href="/topics/Physiology">Physiology</a> | <a
href="/topics/Diet">Diet</a> | <a
href="/topics/Reproduction">Reproduction</a> | <a
href="/topics/Behavior">Behavior</a> | <a
href="/topics/People">People</a> | <a

$result = mysql_query('select count(*) from
if (($result) && (mysql_result ($result , 0) > 0)) {
} else {
die('Invalid query: ' . mysql_error());
$topic = mysql_query ("SELECT Name, Name2, Parent FROM
gztopics AS GZT
 WHERE Parent = '$_GET[topic]'");

<div class="divindex">

while ($row = mysql_fetch_array($topic, MYSQL_ASSOC))
$Display2 = urlencode($row['Name']);
$Display3 = $row['Name'].$row['Name2'];
$Display3 = str_replace(' and', ' &amp;', $Display3);
$Display = '<a
| ';
$url_name = urldecode($_GET['topic']);
$Display = rtrim($Display, '+');

// If you replace + with - in .htaccess, insert this
$Display = str_replace('+', '-', $Display);

echo <<<EOD
echo '</div><!--EndDivIndex-->';

<table id="tabmain">
<td class="tdleft">
<td class="tdcenter">
<div class="divsection" id="divintro">
<p>Biogeography, Continents, Realms, articles about
each continent and realm,
  articles about distribution of various groups,
<p>Biomes, biogeographic regions, freshwater &amp;
<h3>Minor Habitat</h3>
<p>Terrestrial (terrestrial, fossorial, arboreal),
Aquatic (surface, benthic,
  burrower, pelagic, etc.), Aerial</p>
<p>Mammals, Birds, etc.</p>
<p>Head, Cervical Vertebrae, Legs, Feet, etc.</p>
<p>Animal Colors</p>
<p>I can't write about every species, BUT...</p>
<p>1. Write about upper topics.<br />
  2. Create species accounts with a database.<br />
  3. Create a central reference section.<br />
  4. Topics.<br />
  5. Write about select species.<br />
  6. Link to species accounts.<br />
  7. Borrow or purchase species accounts.<br />
  8. Get others to write for you.</p>
<p>&nbsp; </p>
<p> People</p>
  echo "<h1>Mammals</h1>No topic selected";
  echo "
Information about $_GET[topic] species (or genera,
families, etc.) goes here.
MyCode = <?php echo $mycode ?><?php $row['Name']
<div class="divsection" id="divhome"><h2>Home</h2>
<p class="p1st">This is the Home section. On the
Internet, Home usually refers to a websites home page.
At GeoZoo, it also refers to where
a plant or animal lives. This kind of home consists of
three things: distribution, biome or habitat
and minor habitat.</p>
<p>Distribution refers to a species or groups
geographic distrubition. For example, does it live in
North America, Eurasia or both? North Africa or East
Africa? The island of Madagascar?</p>
<p>Suppose some told you a certain animal species
lives in western North America.</p></div>
<div class="divsection" id="divanat"><h2>Anatomy &amp;
<div class="divsection"
<div class="divsection"
<div class="divsection"
<div class="divsection"
<div class="divsection"
<div class="divsection" id="divpeople"><h2>? &amp;
<div class="divsection" id="divlinks"><h2>Books,
Links, etc.</h2></div>
<td class="tdright">Ads
<?php // ?>
<div class="divindex">
echo '<table>';
while ($row = mysql_fetch_array($topic, MYSQL_ASSOC))

echo <<<EOD
     <td><a href=$row[Name]>{$row["Name"]}</a></td>
echo '</table></div><!--EndDivIndex-->';
<div class="divbottom">
<div style="width: 100px; position: absolute; top:
5px; right: 5px;"><img src="/images/icons/vote.gif"
width="100" height="33" alt="Vote!" /></div>

Start your day with Yahoo! - make it your home page 

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message