Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite problem! I need help

         

lfjigu

10:34 pm on Nov 11, 2006 (gmt 0)

10+ Year Member



Hi
I want to change my URL like this:
www.example.com/query.php?q=keyword

to
www.example.com/keyword/

I use this code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^/]+)/ /query.php?q=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /query.php\?q=([^&]+)\ HTTP/
RewriteRule ^query.php$ http://www.example.com/%1/? [R=301,L]

and it work. My problem is:when the url is www.example.com/query.php?q=keyword+keyword

it change to this
www.example.com/keyword+keyword/

how can I replace the"+" to "-", I have read the tutorials,and I still dont know how to do.
any help will be appreciate.Thanks.

[edited by: jdMorgan at 2:27 am (utc) on Nov. 12, 2006]
[edit reason] Example.com [/edit]

jd01

1:56 am on Nov 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Better to change the way the script passes the variables than to try to make the change in htaccess usually... If you decide to go with .htaccess, you will need to 'catch' each occurance of 'is not a +, followed by a +' ([^+]+)\+ and string your variables together.

Maybe someone can think of a way the 'set a flag' or chain the rules together, but usually you need a separate ruleset for each possible number of +s EG Rule 1 = 3 pluses in query_string; Rule 2 = 2 pluses in query_string, etc.

Justin