httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blomstrom <>
Subject [users@httpd] Mod-Rewrite: Changing + to -, _ or .
Date Sun, 21 Aug 2005 02:48:33 GMT
Someone wrote the following mod-rewrite rules for me:

RewriteEngine On
RewriteRule ^test\.htm$ test.php [L]

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

They work fine except for one problem - I don't like
URL's that look like this:

So I want to experiment with other space-filling
characters, primarily -, _ and .

But I can't figure out how to make any of these work.
For example, I can't make a URL with dashes work
whether I change RewriteRule ^topics/([a-zA-Z+]+) to
examples 1, 2 or 3 below:

1. RewriteRule ^topics/([a-zA-Z-]+)
2. RewriteRule ^topics/([a-zA-Z+]-)
3. RewriteRule ^topics/([a-zA-Z-]-)

Do I have to change something in my PHP code, too? On
one forum, someone said I shouldn't use urlencode
and/or urldecode, but I didn't understand why.


echo '';
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, '+'); 

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

Yahoo! Mail for Mobile 
Take Yahoo! Mail with you! Check email on your mobile phone. 

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