Forum Moderators: phranque

Message Too Old, No Replies

replace the "-" with a space

problems with .htaccess

         

kirst

2:24 pm on Sep 10, 2005 (gmt 0)

10+ Year Member



Hi, on my .htaccess I've written:

RewriteEngine On
RewriteRule ^sport/([^/]+)/([^/]+).html sport.php?page=$1&var1=$2&var2=$3 [L]

On my .php page I've this:

<?php echo $_GET['var1']?> ; <?php echo $_GET['var2']?>

So, if digit the url: www.mydomain.xx/sport/soccer/john.html
on my page I'll have
Soccer ; John

but if I digit the url www.mydomain.xx/sport/soccer-team/Liverpool.html
I'll have:
soccer-team ; Liverpool

I would like to replace the "-" in the page in the word "soccer-team" and replace it with a space but I want to keep the "-" in the url.
How can I do this?
I hope you've understood.
Thank you

jonrichd

10:50 am on Sep 11, 2005 (gmt 0)

10+ Year Member



Why not consider dealing with the dash to space problem in the php script you are using to display the page, rather than in .htaccess. something like this:

<?php echo str_replace("-", " ", $_GET['var1'])?>

That way any dashes in the URL get converted to spaces. Useful unless you need the dash character. If that's the case, consider using another delimiter, such as ^ or ~.