httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blomstrom <david_blomst...@yahoo.com>
Subject Re: [users@httpd] Re: Mod-Rewrite: Changing + to -, _ or .
Date Tue, 23 Aug 2005 18:49:16 GMT
--- John Hicks <johnlist@gulfbridge.net> 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 www.geozoo.org/topics. 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:

http://www.geozoo.org/topics/Tundra+Mammals

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

GeoZoo > Topics  >  Home  >  Biomes  >  Tundra  >
Tundra Mammals

...as it should. But the URL features a +, which I
want to get rid of:

http://www.geozoo.org/topics/Tundra+Mammals

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:

http://geozoo/topics/Tundra-Mammals

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

GeoZoo > Tundra-Mammals

...instead of:

GeoZoo > Topics  >  Home  >  Biomes  > Tundra > Tundra
Mammals

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
line: 
$Display = str_replace('+', '-', $Display);

I'm not working on www.geozoo.org/stacks/, 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\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php $_GET['topic'] ?></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<?php
//
http://www.sitepoint.com/forums/showthread.php?t=288246
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"
type="text/css">
<link href="/a1/css/stacks.css" rel="stylesheet"
type="text/css">
</head>

<body>
<div id="divtop">
<br /><br /><br /><br /><br /><br />
<?php
$_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>';
?>
<div id="kidstacks">(<a href=/kids/<?php echo
$_GET['topic'] ?>>Kids version</a>)</div>
<br />
</div><!--EndDivTop-->

<div id="toplinks">
<?php
$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
//
http://www.sitepoint.com/article/hierarchical-data-database/2
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']),
$path);
   }
   return $path;
}

$mypath = get_path($mycode);
$$mypath[$i] = str_replace(' ', '-', $$mypath[$i]);
for($i=0;$i<count($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
href="/reference/">Topics</a></span>
<span id="topworld"><a href="/world/">World</a></span>
<span id="topref"><a
href="/reference/">Reference</a></span>
<span id="topglos"><a
href="/reference/glossary/">Glossary</a></span>
<span id="topcal"><a
href="/calendar/">Calendar</a></span></div>
<div class="topsections">
<span id="topabout"><a href="/about/">About
GeoZoo</a></span>
<span id="topcontact"><a
href="http://www.geobop.org/about/contact/">Contact</a></span>
</div>
</div>
<!--EndTopLinks-->


<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
href="/topics/Misc">Misc.</a></div>



<?php
$result = mysql_query('select count(*) from
gztopics');
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">

<?php
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
href="'.$Display2.''.$row['Name2'].'">'.$Display3.'</a>
| ';
$url_name = urldecode($_GET['topic']);
$Display = rtrim($Display, '+');

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

echo <<<EOD
$Display
EOD;
}
}
echo '</div><!--EndDivIndex-->';
?>

<table id="tabmain">
<tr>
<td class="tdleft">
</td>
<td class="tdcenter">
<div class="divsection" id="divintro">
<h2>Home</h2>
<h3>Distribution</h3>
<p>Biogeography, Continents, Realms, articles about
each continent and realm,
  articles about distribution of various groups,
etc.</p>
<h3>Habitat/Biome</h3>
<p>Biomes, biogeographic regions, freshwater &amp;
marine</p>
<h3>Minor Habitat</h3>
<p>Terrestrial (terrestrial, fossorial, arboreal),
Aquatic (surface, benthic,
  burrower, pelagic, etc.), Aerial</p>
<p>Locomotion</p>
<h2>Anatomy/Appearance</h2>
<p>Mammals, Birds, etc.</p>
<p>Head, Cervical Vertebrae, Legs, Feet, etc.</p>
<h3>Locomotion</h3>
<p>&nbsp;</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>
<h2>Senses</h2>
<p>x</p>
<h2>Physiology</h2>
<p>x</p>
<h2>Diet</h2>
<p>x</p>
<h2>Reproduction</h2>
<p>x</p>
<h2>Behavior</h2>
<p>x</p>
<p> People</p>
<p>x</p>
<?
if(!isset($_GET['topic']))
{
  echo "<h1>Mammals</h1>No topic selected";
}
else
{
  echo "
<strong>Families</strong>
<strong>$_GET[topic]</strong>
Information about $_GET[topic] species (or genera,
families, etc.) goes here.
  ";
}
print_r($topic); 
?>
MyCode = <?php echo $mycode ?><?php $row['Name']
?></div>
<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;
Appearance</h2></div>
<div class="divsection"
id="divsenses"><h2>Senses</h2></div>
<div class="divsection"
id="divphys"><h2>Physiology</h2></div>
<div class="divsection"
id="divdiet"><h2>Diet</h2></div>
<div class="divsection"
id="divrepro"><h2>Reproduction</h2></div>
<div class="divsection"
id="divbvr"><h2>Behavior</h2></div>
<div class="divsection" id="divpeople"><h2>? &amp;
People</h2></div>
<div class="divsection" id="divlinks"><h2>Books,
Links, etc.</h2></div>
</td>
<td class="tdright">Ads
<?php // ?>
<div class="divindex">
<?php
echo '<table>';
while ($row = mysql_fetch_array($topic, MYSQL_ASSOC))
{

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






		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message